View Full Version : Easy prompt for string? (Input equivalent of MessageBox)
06 June 2011, 08:42 PM
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.
06 June 2011, 02:44 PM
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.
06 June 2011, 04:56 PM
Hello again Swordslayer :D
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.
06 June 2011, 07:17 PM
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):
stringQuery = rollout stringQuery "String Query"
fn launch label: =
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
on etInput entered str do
returnStr = str
myCoolDialogs = myCoolDialogs() -- as there are variables, an instance is needed
result = myCoolDialogs.stringQuery.launch label:"Enter your credentials"
format "Returned String: %\n" result
06 June 2011, 10:34 AM
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
06 June 2011, 12:11 PM
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.
06 June 2011, 12:31 PM
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.
06 June 2011, 12:37 PM
Thanks! And those images look great! More artists should write programming tuts :D
06 June 2011, 12:37 PM
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.