Easy prompt for string? (Input equivalent of MessageBox)

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Display Modes
  06 June 2011
Question Easy prompt for string? (Input equivalent of MessageBox)

Hi,

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
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.
__________________
Scripts :: linkedin
 
  06 June 2011
Hello again Swordslayer

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.

Thanks!
 
  06 June 2011
Hello

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
 (
 	labelStr,
 
 	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: %\n" result
 
__________________
Scripts :: linkedin

Last edited by Swordslayer : 06 June 2011 at 07:19 PM.
 
  06 June 2011
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 
__________________
Regards,
Pete

Read my technical blog - lonerobot.net
 
  06 June 2011
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.

Thanks!
 
  06 June 2011
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.

http://lonerobot.net/?p=1125
__________________
Regards,
Pete

Read my technical blog - lonerobot.net
 
  06 June 2011
Thanks! And those images look great! More artists should write programming tuts
 
  06 June 2011
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:42 PM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.