MEL How-To #59

Back · Previous · Next Maya

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