Monday, April 25, 2016

Maya mode OptionMenu

I do a lot of editing to the source code of Maya's UI to customize and add or remove items.

 One of my personal pet peeves is the "mode" button in the upper left corner of Maya's status bar.   It's huge, I use the hotbox predominantly so it's useless to me, and it doesn't have a "collapse bar" so you can hide it like all the other buttons and ui items on the status bar.

 The purpose of the mode button is to change what menu set is available, like "modeling" , "rendering" etc. 








There isn't that much space on a screen, and this button already is connected to a bunch of hotkeys { which I also don't use}, So I find it very redundant.. Unless I am making  a custom menuSet.. which I guess now I'll have to explain later... but you can make your own menus that show up in the hotbox or menu .. but I'll do that later.. 

in any case the nice thing is this optionMenu is easy to get at , as Maya has already made it a global variable by default

print $gMenuModeButton;

will give you the actual name of the optionMenu, which will change each time you open Maya 

in this instance I get the following
//MayaWindow|toolBar1|MainStatusLineLayout|formLayout5|flowLayout1|optionMenuForm|menuMode

note the numbers in the names, this is due to Maya not caring what those layout's names are . but the Menu Mode Button ,  Maya wants to know because it is accessed all over the place to help show menus and ui ..  So the easiest way for the developers to do that, was to make a it a global variable.. There are a lot of these and they almost all start with 'g'

so even though they named it "button" it's actually an optionMenu. ( which I think I only know from digging into the statusline.mel code) 

So now that you know what it is you can do all sorts of things to it, like hide it 

optionMenu -e -vis 1 $gMenuModeButton

or make it smaller. 
optionMenu -e -width 1  $gMenuModeButton








It's super important to use the -e or -edit flag when running the optionMenu command, or you will end up adding a new optionMenu somewhere in maya.. which of course can be dangerous, and not what you want.

You could add a shelf button or menu somewhere to show/hide the menu, but I just put the above command into my userSetup.mel and let Maya collapse it on start up.

 If I really wanted to dig in I would add a collapse bar in front of the optionMenu, but since I almost never ever use it.. I haven't bothered to do so.

if you want to do other edits to the menu just check out the help docs. 
help -doc optionMenu;



Lately I've been playing with the "custom" menu sets and so I've only been shrinking the mode button down, so I can still access it when I want to without having to run code to reveal it again.. and I can live with 5 -10 pixel width vs 100
( you can't read the menu names, but I know custom is at the bottom so I just click the bottom one) 

hth

-=s




No comments:

Post a Comment