View Single Post
# 4 11-12-2004 , 01:39 AM
Registered User
Join Date: Aug 2004
Posts: 24
When you set up the option menu, you don't need to -q flag because you are creating it, not querying it. Latter when you want to query it in another part of your code you use the -q flag.

For example;

global proc optMenu2()
{

string $selected = "orange";

window -menuBar true -maximizeButton false -title "Option Menu" -iconName "optMenu2_I" -w 200 -h 150 optMenu2a_w;
columnLayout;

rowColumnLayout -numberOfRows 3;
optionMenu -label "Attributes" optMenu2_Menu;

menuItem -label "orange";
menuItem -label "blue";
menuItem -label "yellow";

showWindow optMenu2a_w;
}


All I've changed here is the optionMenu line. I took out the -q and the -cc flags and named it optMenu2_Menu.
If you copy and past the above code into maya and then run it (type optMenu2), you will get your window. From here you can query the menu from the script editor by typing;

optionMenu -q -v optMenu2_Menu;

This should allow you to select a menu item and then use the script edit to query it.

If you want to set somthing up when the menu item is changed, this is when you use the -cc flag.

For example copy and paste in the code below to the script editor and then select a new item from the menu. The -cc flag runs the new proc PrintMenu() whenever the menu item changes. This new proc simply querys the menu and prints the results to the scipt editor (so have it open when you change somthing).



// Start Copy Here////////////////////////////////////////
///////////////////////////////////////////////////////////////

global proc PrintMenu()
{
string $MenuValue = `optionMenu -q -v optMenu2_Menu`;

print ("\n\nThe menu item is : " + $MenuValue );
}

global proc optMenu2()
{

if (`window -exists optMenu2a_w`)
deleteUI optMenu2a_w;

string $selected = "orange";

window -menuBar true -maximizeButton false -title "Option Menu" -iconName "optMenu2_I" -w 200 -h 150 optMenu2a_w;
columnLayout;

rowColumnLayout -numberOfRows 3;
optionMenu -label "Attributes" -cc "PrintMenu" optMenu2_Menu;

menuItem -label "orange";
menuItem -label "blue";
menuItem -label "yellow";

showWindow optMenu2a_w;
}

optMenu2;

// EndCopy Here//////////////////////////////////////////
///////////////////////////////////////////////////////////////


I hope this helps

Richard


----------------------------------------------
Richard Cheek
https://www.freelance-animation.com
----------------------------------------------