PluginRegistrar.RegisterEvent

導入

v5.0

詳細

PluginItemオブジェクトとしてイベントを登録します。このプラグイン項目は、EventInfoオブジェクトの作成に使用できます(登録イベントに関連付けられているアクションにユーザ定義の関数をバインドします)。

スクリプト 構文

oReturn = PluginRegistrar.RegisterEvent( Name, Type );

戻り値

PluginItem

パラメータ

パラメータ タイプ 詳細
Name String 登録するカスタムイベントの名前。文字から開始し、英数字とアンダースコア(_)記号のみを使用する必要があります。

イベント名は、OnEventコールバック関数に名前をつけるときに使用されます。たとえば、"MySelectionChange"という名前のイベントの OnEventコールバックは、"MySelectionChange_OnEvent"になります。イベント名にスペースが含まれている場合("My Selection Change"など)、OnEventコールバック関数名ではスペースを削除する必要があります("MySelectionChange_OnEvent"など)。

この名前は、XSIApplication.EventInfosによって戻されるEventInfoCollection内のイベントの名前にもなります。
siEventID 登録するイベントのタイプ

注:siOnWindowEventsiOnTimersiOnCustomFileImportsiOnCustomFileExportの識別子はサポートされていません。このメソッドではなく、siOnTimer イベントタイプのPluginRegistrar.RegisterTimerEventか、siOnCustomFileImportおよび SiOnCustomFileExport イベントタイプのPluginRegistrar.RegisterConverterEventを使用してください。

JScript の例

/*-------------------------------------------------------------------
        The example shows how to register and implement an event plug-in.
        README: Copy and paste the example into the script editor 
        and run (F5).
        The events will now be listed in the plugin manager's pluginitem
        tab and under the plugin node in the plugin browser tab.
        The events will fire whenever there the user creates a newscene,
        either from the menu File->New Scene or from scripting using
        the NewScene() command.
-------------------------------------------------------------------*/
function  XSILoadPlugin( in_reg )
{
        in_reg.Author = "Softimage Co." 
        in_reg.Name = "PluginRegistrar.RegisterEvent Example" 
        // register the event plug-in item 
        in_reg.RegisterEvent( "ExRegisterEvent_BeginNewScene", siOnBeginNewScene );
        in_reg.RegisterEvent( "ExRegisterEvent_EndNewScene", siOnEndNewScene );
        // register a command to illustrate events firing.
        in_reg.RegisterCommand( "ExRegisterEventDemo", "ExRegisterEventDemo" );
        return true;
} 
function  ExRegisterEvent_BeginNewScene_OnEvent( in_context )
{
        Application.LogMessage( "ExRegisterEvent_BeginNewScene_OnEvent called" );
}
function  ExRegisterEvent_EndNewScene_OnEvent( in_context )
{
        Application.LogMessage( "ExRegisterEvent_EndNewScene_OnEvent called");
}
function  ExRegisterEventDemo_Execute()
{
        NewScene();
}
//--------------------------------------------------------------------
// Code to bootstrap example into system
//--------------------------------------------------------------------
function ExampleSourceCode()
{
        return "//XSISDK Doc Example\n" +
                ExRegisterEvent_BeginNewScene_OnEvent.toString() + "\n" + 
                ExRegisterEvent_EndNewScene_OnEvent.toString() + "\n" + 
                ExRegisterEventDemo_Execute.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             = "ExPluginRegistrarRegisterEvent";
        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);       
        }
        // run demo
        ExRegisterEventDemo();
}

関連項目

Plugin.Items Definition Callbacks for Events