一半君的总结纸

听话只听一半君

#59 How can I create a hotkey to cycle through the Shelf tabs?

The first thing you’ll need is the path to the main Shelf. Maya stores the UI identity of the Main Shelf in the global string variable $gShelfTopLevel.

This provides you with the tabLayout that generates the Shelf tabs, and from here it’s just a matter of a couple queries and specifying the new tab to choose.

global proc nextShelfTab()
{
  // Get Maya's global Shelf identifier
  global string $gShelfTopLevel;

  // How many tabs are in the Shelf?
  int $numTabs = `tabLayout -q -nch $gShelfTopLevel`;

  // What's the currently selected Shelf tab?
  int $currentTab = `tabLayout -q -sti $gShelfTopLevel`;

  // Roll the current Shelf one tab to the right (looping to first)
  $currentTab = ( $currentTab % $numTabs ) + 1;

  // Set the Shelf to the new tab
  tabLayout -e -sti $currentTab $gShelfTopLevel;
}

Related How-To’s

Tuesday, March 20, 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 博主赞过: