Maxscript Dialog/RolloutFloater Return

Maxscript Dialog/RolloutFloater Return

Anonymous
Not applicable
1,903 Views
2 Replies
Message 1 of 3

Maxscript Dialog/RolloutFloater Return

Anonymous
Not applicable

For the life of me I cannot figure out how to get a dialog or a rollout floater to return what I want it to. It is basically a dialog that asks the user if they want to do one of three things.

 

fn createQueryDialog =
(
	rollout messageView ""
	(
		button overwrite_btn "Overwrite" height:24 width:80 pos:[250,5]
		button create_btn "Create New" height:24 width:80 pos:[250,32]
		button append_btn "Append" height:24 width:80 pos:[250,60]
		button cancel_btn "Cancel" height:24 width:322 pos:[8,88]
		
		label answer_label "cancel" visible:false
		
		on overwrite_btn pressed do
		(
			answer_label.text = "overwrite"
			destroyDialog messageView
		)
		on create_btn pressed do
		(
			answer_label.text = "create"
			destroyDialog messageView
		)
		on append_btn pressed do
		(
			answer_label.text = "append"
			destroyDialog messageView
		)
		on cancel_btn pressed do
		(
			answer_label.text = "cancel"
			destroyDialog messageView
		)
		on messageView close do
		(
			Return answer_label.text
		)
	)
	createDialog messageView 344 130
)

 

I just want it to return me a string based on what button is pressed. The same as their premade yesNoCancelBox returns whatever button you press as a name.

 

0 Likes
Accepted solutions (1)
1,904 Views
2 Replies
Replies (2)
Message 2 of 3

Swordslayer
Advisor
Advisor
Accepted solution

As it's a query dialog, I would make it modal, and then it's just a question of returning something after the createDialog part of the code finishes executing. The scope of the result variable doesn't really matter, it can be a higher scope too, I just like keeping related things close.

 

(
	local queryDialog = rollout queryDialog "" width:344 height:130
	(
		local result

		button overwrite_btn "Overwrite" height:24 width:80 pos:[250,5]
		button create_btn "Create New" height:24 width:80 pos:[250,32]
		button append_btn "Append" height:24 width:80 pos:[250,60]
		button cancel_btn "Cancel" height:24 width:322 pos:[8,88]

		fn init val:undefined =
		(
			try destroyDialog queryDialog catch()
			result = val
			createDialog queryDialog modal:true
			result
		)

		fn switchAndClose val =
		(
			result = val
			destroyDialog queryDialog
		)

		on overwrite_btn pressed do switchAndClose #overwrite
		on create_btn pressed do switchAndClose #create
		on append_btn pressed do switchAndClose #append
		on cancel_btn pressed do destroyDialog queryDialog
	)

	queryDialog.init()
)

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

That worked perfectly thank you very much.

0 Likes