PDA

View Full Version : Selecting menuItem from optionMenu


rainbowdemon
01-20-2011, 02:31 PM
Hello! Right I feel really dumb asking this question, as I am sure the answer is something really obvious but anyways..

How do I select a different menuItem using mel? Here is example of my code

string $window = `window`;
columnLayout;
optionMenu -label "versions" -changeCommand test versionNumber;
menuItem -label "one" ver1;
menuItem -label "two" ver2;
menuItem -label "three" ver3;
showWindow $window;

proc test()
{
string $versionNumber = `optionMenu -q -v versionNumber`;
print $versionNumber;
print "\n";

optionMenu -e -sl ver1;
}


So I have 3 menuItems. Say I want to select a second one, have the selection printed, and then automatically have the optionMenu switch back to the first menuItem in the optionMenu..

So it is really just the last line of code that should be responsible for this action, but as I fail to find proper syntax the task is really driving me nuts. Many thanks for any help/pointers :)

NaughtyNathan
01-20-2011, 03:09 PM
the -sl flag takes an int, not a string, and you haven't specified the name of the optionMenu you are trying to edit!

optionMenu -e -sl 1 versionNumber;
or:
optionMenu -e -v "one" versionNumber;:nathaN

rainbowdemon
01-20-2011, 03:12 PM
Doh!! Thank you so much, it works perfect with your code. And a separate thanks for the explanation.

Sorry for such a stupid question, but at least maybe this post will help someone as tough headed as me in the future))

CGTalk Moderation
01-20-2011, 03:12 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.