/*
Example showing how custom commands
can be defined and added to custom menus inside a
self installed plug-in.
Adds two entries to the "Window" menu
The first item is greyed out
The second item allows you to enable or disable the first item.
*/
function XSILoadPlugin( in_reg )
{
// Called on startup of Softimage to defined
// what is contained in the script. (We could potentially
// implement many PluginItems in the same script)
in_reg.Author = "Softimage SDK Team" ;
in_reg.Name = "SDK Example - Enabled Command" ;
in_reg.Major = 1 ;
in_reg.Minor = 1 ;
in_reg.RegisterMenu( siMenuMainWindowID, "DemoMenu", false ) ;
in_reg.RegisterCommand( "DemoDisabled", "DemoDisabled" );
in_reg.RegisterCommand( "EnableDemoDisabled", "EnableDemoDisabled" );
return true ;
}
function DemoMenu_Init( in_oCtxt )
{
var menu = in_oCtxt.Source
menu.Name = "&Custom Deform" ;
menu.AddCommandItem( "&Demo Disabled", "DemoDisabled" ) ;
menu.AddCommandItem( "&Toggle Demo Disabled", "EnableDemoDisabled" ) ;
}
function DemoDisabled_Init(in_oCtxt)
{
var cmd = in_oCtxt.Source ;
cmd.Enabled = false ;
cmd.ReturnValue = false ;
}
function DemoDisabled_Execute()
{
LogMessage( "Thanks for enabling me finally" ) ;
}
function EnableDemoDisabled_Init(in_oCtxt)
{
var cmd = in_oCtxt.Source ;
cmd.Enabled = true ;
cmd.ReturnValue = false ;
}
function EnableDemoDisabled_Execute()
{
var cmd = Application.Commands( "DemoDisabled" ) ;
// Toggle the enabled bit
if ( cmd.Enabled )
cmd.Enabled = false ;
else
cmd.Enabled = true ;
// Update the definition
cmd.Update() ;
}
|