//--------------------------------------------------------------------
// This example logs information for all installed events
//
// README: Copy and paste the example into the script editor
// and run (F5).
//--------------------------------------------------------------------
function ExEventInfosDemo()
{
var eEventInfos = new Enumerator(Application.EventInfos);
for ( ;!eEventInfos.atEnd(); eEventInfos.moveNext() )
{
var e = eEventInfos.item();
LogMessage( "************" );
LogMessage( "Event: " + e.event);
LogMessage( "\tType: " + e.Type);
LogMessage( "\tName: " + e.name);
LogMessage( "\tToken: " + e.Token);
LogMessage( "\tHandler: " + e.Handler);
LogMessage( "\tFilename: " + e.Filename);
LogMessage( "\tLanguage: " + e.Language);
LogMessage( "\tAttributes: " + ((e.Attributes) ? e.Attributes.valueOf() : "null" ));
LogMessage( "\tCustomData: " + ((e.CustomData) ? e.CustomData.valueOf() : "null" ));
}
}
function XSILoadPlugin( in_reg )
{
in_reg.Name = "XSIApplication.EventInfos Example";
in_reg.Author = "Softimage Co.";
in_reg.Major = 1;
in_reg.Minor = 0;
in_reg.URL = "www.softimage.com";
in_reg.Email = "xsi@softimage.com";
in_reg.Categories = "Demo";
in_reg.RegisterEvent("ExEventInfos_SelectionChange", siOnSelectionChange );
return true;
}
function ExEventInfos_SelectionChange_OnEvent( in_ctxt )
{
LogMessage("ExEventInfos_SelectionChange_OnEvent");
}
//--------------------------------------------------------------------
// Code to bootstrap example into system
//--------------------------------------------------------------------
function ExampleSourceCode()
{
return "// XSISDK Doc Example\n" +
ExEventInfos_SelectionChange_OnEvent.toString() + "\n" +
XSILoadPlugin.toString();
}
// if we are running from script editor save code to
// examples addon folder in the user's directory.
if (GetUserPref("ScriptingSessionActive"))
{
var ex_name = "ExXSIApplicationEventInfos";
var ex_subfolder = "Plugins";
var ex_folder = "XSISDKDocExamples";
var ex_langsuffix = ".js";
CreateAddonDirectories( InstallationPath(siUserPath), ex_folder );
var fso = XSIFactory.CreateActiveXObject("Scripting.FileSystemObject");
var filename = XSIUtils.BuildPath(
InstallationPath(siUserAddonPath),
ex_folder,
"Application",
ex_subfolder,
ex_name+ex_langsuffix );
if (!fso.FileExists(filename))
{
var f = fso.CreateTextFile ( filename );
f.write( ExampleSourceCode() );
f.close();
Application.LoadPlugin(filename);
}
ExEventInfosDemo();
}
|