一半君的总结纸

听话只听一半君

#48 How do I toggle the visibility of the Model panels’ menu bars?

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

toggleMenuBarsInPanels

This is found in the MEL script:

<MAYA_INSTALL_DIR>\scripts\startup\createPrefWndUI.mel

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.

Yes, this does use a stored state value and assumes it accurately reflects the current state of the UI. While I’m not a fan of coding assumptions such as this, there is no query mechanism for the ‘toggleMenuBarsInPanels’ function so we gotta take what we can get.

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

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: