Easy prompt for string? (Input equivalent of MessageBox)



Is there an easy way to display a modal dialog prompting the user for a string? Without creating a new dialog? I.e. MessageBox but it takes a string instead of a mouse event.


None that I’m aware of, in maxscript you only have messageBox, queryBox and yesNoCancelBox, in dotnet AbortRetryIgnore, OK, OKCancel, RetryCancel, YesNo and YesNoCancel message boxes.

What’s so wrong abot creating another dialog, though? It can be nested in the main rollout scope if you want to avoid creating a new global variable for it and do whatever you want to its look and functioning.


Hello again Swordslayer :smiley:

Yes, I ended up creating a new rollout and a little function to create it and return a string that basically does what the non-existent function I was asking about did.

I thought I’d ask as there are usually shortcuts for things like this, and if available, why not use them.
But it was much easier than I thought to make one and I can reuse it.



Hello :slight_smile:

Well, maxscript makes it really easy when it comes to basic UI design. If you plan on using this kind of querybox often, you can always make a custom struct with predefined, custom tailored rollouts, something like this (a bit rough around the edges but the basic functionality is there):

struct myCoolDialogs
 	stringQuery = rollout stringQuery "String Query"
 		local returnStr
 		label lblHeader
 		editText etInput
 		fn launch label: =
 			destroyDialog myCoolDialogs.stringQuery
 			if label != unsupplied then
 				myCoolDialogs.labelStr = label
 			else myCoolDialogs.labelStr = "Enter some text:"
 			createDialog myCoolDialogs.stringQuery modal:true
 			returnStr -- only put it here if the dialog is modal
 		on stringQuery open do
 			lblHeader.text = myCoolDialogs.labelStr
 			setFocus etInput
 		on etInput entered str do
 			destroyDialog myCoolDialogs.stringQuery
 			returnStr = str
 myCoolDialogs = myCoolDialogs() -- as there are variables, an instance is needed
 result = myCoolDialogs.stringQuery.launch label:"Enter your credentials"
 format "Returned String: %
" result


There is a class in maxcustomcontrols.dll in the dotnet SDK that is used in the scene explorer. It’s called “RenameInstanceDialog”- this can be utilised for other tasks if you like -

-- instantiate the object
theObj = dotNetObject "MaxCustomControls.RenameInstanceDialog" "Type in new name here"
theobj.text ="A terribly useful dotnet input dialog"
DialogResult = theObj.Showmodal()

--test if the ok button was pressed
dotnet.compareenums TheObj.DialogResult ((dotnetclass "System.Windows.Forms.DialogResult").OK)
--get the new text string
NewStringEntered = theobj.InstanceName 


Hi Swordslayer, LoneRobot,

Thanks for the useful code! I tried to encapsulate mine in a struct but couldn’t make it work, so gave up and moved onto another part of the tool, so its good to see how to do it.

Nice idea using .net types; i’ll have to get some more practice at this, im finding being able to call on .net very useful but I can’t see the pattern of why some objects and methods I can use and some I cannot. I’m glad to see I can use it for the UI aswell.



I recently posted part one of a tutorial which should help you with an introduction to dotnet in 3dsmax, including the difference between classes and objects. It was written to clarify the area you are talking about, so you may find it useful to get you up and running.



Thanks! And those images look great! More artists should write programming tuts :smiley:


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.