MEL How-To #48

Back · Previous · Next Maya

How do I toggle the visibility of the Model panels' menu bars?

The command that Maya uses to toggle the panel menuBars is:


This is found in the MEL script:


Frankly, this function doesn't make sense. It's self-described as a toggle, yet requires a 'true'/'false' argument to actually set the state. Weird.

To implement your own toggle:

global proc actuallyToggleMenuBarsInPanels()
  global int $gUseMenusInPanels;
  toggleMenuBarsInPanels( !$gUseMenusInPanels );

Call your ‘actuallyToggleMenuBarsInPanels’ procedure to alternate between menus / no-menus in panels. This effect will be stored as the user's global preference.

If you want to toggle the menuBar for only the active panel:

global proc toggleMenuBarInPanelWithFocus()
  string $panel = `getPanel -withFocus`;
  panel -e -mbv ( !`panel -q -mbv $panel` ) $panel;

This is performed in-place and will not affect the user's preference.

Related How-To's

Monday, May 21, 2001