Registering Event Handlers

You register event handlers in XSILoadPlugin, which is called when Softimage loads a self-installing plug-in. XSILoadPlugin gets a PluginRegistrar object from Softimage, and you use the RegisterEvent method to register handlers for different events.

C++ Example: Registering an event handler

    XSIPLUGINCALLBACK CStatus XSILoadPlugin( PluginRegistrar& in_reg )
    {
       in_reg.PutAuthor(L"Event Wizard User");
       in_reg.PutName(L"MyCppEventHandlers");
       in_reg.PutVersion(1,0);

       in_reg.RegisterEvent( L"MyOnSelectionChange", siOnSelectionChange );

       return CStatus::OK;
    }

• The first parameter to RegisterEvent is the name of the event handler. This name is used to name the callback function that implements an event handler. For example, the OnEvent callback for an event handler named "MyOnSelectionChange" is "MyOnSelectionChange_OnEvent".

This name is also the name of the event in the list of installed events returned by XSIApplication.EventInfos.

The first character in an event handler name should be a letter. Subsequent characters can be letters, numbers, underscore (_) characters, or spaces. If an event handler name contains spaces (for example, "My Event"), then you must remove the spaces in the callback function name (for example, "MyEvent_OnEvent").

• The second argument is the siEventID of the event that triggers the OnEvent callback.

Autodesk Softimage v7.5