一半君的总结纸

听话只听一半君

#47 How do I toggle between ‘Hide UI Elements’ and ‘Show UI Elements?’

The general MEL command for this is:

setAllMainWindowComponentsVisible <true|false>;

However, this is not a toggle. Nor does it have a query mechanism to determine in what state it is currently in, or for what state it was last called. And, passing ‘true’ doesn’t mean “make them visible” but rather “return them to their state before they were explicitly hidden.”

You have a few options:

  1. Pick one of the UI elements and use its visibility to determine if you are toggling the works on or off. For example, if you want to base it on the Time Slider:
    setAllMainWindowComponentsVisible( !isTimeSliderVisible() );
    

    Or the Shelf:

    setAllMainWindowComponentsVisible( !isShelfVisible() );
    
  2. Use your own optionVar to store the last toggled state, and use its complement as the visibility:
    int $globalUIVisibilityFlag = true;
    
    if ( `optionVar -exists globalUIVisibilityFlag` )
      $globalUIVisibilityFlag = `optionVar -q globalUIVisibilityFlag`;
    
    $globalUIVisibilityFlag = !$globalUIVisibilityFlag;
    
    setAllMainWindowComponentsVisible $globalUIVisibilityFlag;
    optionVar -intValue globalUIVisibilityFlag $globalUIVisibilityFlag;
    

    However, this could prove an inconvenience. As alluded to above, the setAll…() function doesn’t specifically turn the UI elements on and off. It turns them off and restores them to their last visible state. If everything is already invisible when your own script asks everything to be invisible, the setAll…() script will remember everything as invisible and you’ll have to manually toggle everything back on again.

  3. Write your own hard-toggle script that specifically hides all UI elements but also specifically unhides the UI elements that you want on.

 

Related How-To’s

Wednesday, November 29, 2000

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 博主赞过: