View Full Version : Selecting menuItem from optionMenu

01 January 2011, 03: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`;
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 :)

01 January 2011, 04: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;
optionMenu -e -v "one" versionNumber;:nathaN

01 January 2011, 04: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 January 2011, 04: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.