一半君的总结纸

听话只听一半君

#59 如何创建一个快捷键来切换工具架(Shelf tabs)?

首先需要得到 Shelf ui的完整路径. Maya 把 UI 的名字都保存在全局变量里( global string variable),工具架的名字是 $gShelfTopLevel.
如果想看到所有的全局变量,可以用

env;
// Result: $gScriptedModelEditorTypes $gScriptedModelEditorList ...

上面的$gShelfTopLevel其实是一个 tabLayout ,ui具有父子关系,$gShelfTopLevel的children就是Shelf tabs们, 剩下的工作就只是查询现在是哪个tab,以及你想换去哪个tab了.

global proc nextShelfTab()
{
  // 要使用已经存在了的全局变量,必须先这么声明一下
  global string $gShelfTopLevel;

  // 在Shelf上一共有多少个tab?
  int $numTabs = `tabLayout -q -nch $gShelfTopLevel`;

  // 现在选择了的Shelf tab是哪个?
  int $currentTab = `tabLayout -q -sti $gShelfTopLevel`;

  // 把当前选择的tab的index+1(就得到了下一个右边的tab的index)
  $currentTab = ( $currentTab % $numTabs ) + 1;

  // 设置需要选择的tab的index为currentTab
  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 博主赞过: