v5.0
PluginItem オブジェクトとしてイベントを登録します。このプラグイン項目は、EventInfo オブジェクトの作成に使用できます(登録イベントに関連付けられているアクションにユーザ定義の関数をバインドします)。
PluginItem PluginRegistrar.RegisterEvent( String in_eventName, siEventID in_eventID ); |
oReturn = PluginRegistrar.RegisterEvent( Name, Type ); |
パラメータ | タイプ | 説明 |
---|---|---|
Name | String |
登録するカスタムイベントの名前。文字から開始し、英数字とアンダースコア(_)記号のみを使用する必要があります。 イベント名は、OnEvent コールバック関数に名前をつけるときに使用されます。たとえば、"MySelectionChange"という名前のイベントの OnEvent コールバックは、"MySelectionChange_OnEvent"になります。イベント名にスペースが含まれている場合("My Selection Change"など)、OnEvent コールバック関数名ではスペースを削除する必要があります("MySelectionChange_OnEvent"など)。 この名前は、XSIApplication.EventInfosによって戻されるEventInfoCollection内のイベントの名前にもなります。 |
Type | siEventID |
登録するイベントのタイプ 注:siOnWindowEvent、siOnTimer、siOnCustomFileImport、siOnCustomFileExport の識別子はサポートされていません。このメソッドではなく、siOnTimer イベントタイプの PluginRegistrar.RegisterTimerEvent か、siOnCustomFileImport および SiOnCustomFileExport イベントタイプの PluginRegistrar.RegisterConverterEvent を使用してください。 |
/*------------------------------------------------------------------- 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(); } |