一半君的总结纸

听话只听一半君

#09 How do I find out which items are highlighted/selected in the MultiLister?

// getMultiListerSelection  v1.1  (28 July 1999)
//
// MEL procedure for Maya
//
// by Bryan Ewert
//    http://www.ewertb.com
//    maya@ewertb.com
//
//    H2O Entertainment Corporation
//    Calgary, Canada
//    http://www.h2oent.com

// PURPOSE
//   Determine what is highlighted or selected in the MultiLister

// INPUTS
//   none

// RESULTS
//   A string array containing all highlighted or selected items from the
//   MultiLister

proc string[] getMultiListerSelection()
{
  string $targets[];

  // Get the MultiLister panel.  There _should_ be only one
  // of these.
  string $scriptPanels[] = `getPanel -scriptType "multiListerPanel"`;

  // Just in case...
  if ( size( $scriptPanels ) > 1 )
  {
    warning ( "More than one active multiListerPanel!" );
  }

  string $nameRoot = $scriptPanels[0];

  // Get the control for the panel.
  // Append the Panel name to get the "topLayout"
  string $control = `scriptedPanel -q -control $nameRoot`;

  // If no control is present, MultiLister is not open
  if ( "" != $control )
  {
    string $topLayout = $control + "|" + $nameRoot;

    // And finally, the active MultiLister
    $theLister = `findActiveLister $topLayout $nameRoot`;

    if ( `listerEditor -exists $theLister` )
    {
      // Code unabashedly copy and paste from 'buildMultiListerEditMenu.mel'

      int $inSelectMode = `listerEditor -q -inSelectMode $theLister`;

      if($inSelectMode == 0)
      {
        // get highlight list
        $targets = `listerEditor -q -highlight $theLister`;
      }
      else
      {
        $targets = `ls -sl`;
      }
    }
  }

  return $targets;
}
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 博主赞过: