PDA

View Full Version : Maya MEL simple textFieldGrp user input getting problem


Zhbdcafe
07-19-2012, 08:07 PM
hi, i am just a beginner in MEL and trying to create a textField and get the user input. but whenever i change the text in the field i still get the previous text. How to get the current user input? Plz hlp!

here is my code
string $myField = `textFieldButtonGrp -label "the_label" -text "some_text" -
buttonLabel "btn"`;
string $currentInput = `textFieldGrp -q -text $myField`;
print($currentInput);

benio33
07-19-2012, 08:26 PM
I don't know what you're after, but in general your code is ok. Try with a window and buttons - like this:

string $window = `window -title "Long Name"
-iconName "Short Name"
-widthHeight 200 55`;
columnLayout -adjustableColumn true;
string $myField = `textFieldButtonGrp -label "the_label" -text "some_text" -buttonLabel "btn"`;
button -label "Print Text" -command ("string $currentInput = `textFieldGrp -q -text $myField`;print($currentInput + \"\\n\")");
button -label "Close" -command ("deleteUI -window " + $window);
setParent ..;
showWindow $window;

jgibz
07-19-2012, 09:39 PM
Great basic model by benio33, seeing as you're a beginner it's helpful to get a bit of explanation. The window containing the textFieldGrp also has a button. When clicked it will gather text from the field through the -command flag, this can be used to query a textFieldGrp, call a function, execute a command, etc. In your case the variable is being declared and initialized at the same time. Try declaring it first then use the button for the the initialization.


string $currentInput; //declared earlier at the beginning of your script.

button -label "get text" -command "$currentInput = `textFieldGrp -q -text $myField`";

Zhbdcafe
07-20-2012, 04:40 AM
Thank you very much dude. after passing a painfull time your reply has just solved my issue

Zhbdcafe
07-20-2012, 04:42 AM
Great basic model by benio33, seeing as you're a beginner it's helpful to get a bit of explanation. The window containing the textFieldGrp also has a button. When clicked it will gather text from the field through the -command flag, this can be used to query a textFieldGrp, call a function, execute a command, etc. In your case the variable is being declared and initialized at the same time. Try declaring it first then use the button for the the initialization.


string $currentInput; //declared earlier at the beginning of your script.

button -label "get text" -command "$currentInput = `textFieldGrp -q -text $myField`";


Thank you very much for a basic information for a beginner like me

CGTalk Moderation
07-20-2012, 04:42 AM
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.