What is a Custom Event?

Events enable clients to react to specific actions initiated by users such as object selection, or non user-initiated actions such as timers or frame changes.

What Do I Need To Know about Events?

Event handling is composed of three things:

an event—a notification that occurs in response to an action, such as:

- pressing a mouse button or a key

- state change, such as an event not initiated by a user

- etc.

an event handler—a function associated to an event that receives control when the corresponding event occurs.

event binding—the action of associating a specific event to an event handler; in general, clients will setup an event sink object in order to handle a specific set of events

The life cycle of an event begins when the action or condition that initiates the event takes place and ends when the event handler has finished processing the event. A typical flow of events goes like this:

1. A user event or non-user event is initiated.

2. An event is fired which notifies the event sink.

3. The event handler processes the event or simply ignores it.

Event Caching

By default all connection information is cached when an event is bound by the user, which means that all events in the cache will get reconnected automatically the next time XSI starts.

Event caches are loaded at startup from the $factory, $workgroup, and $user directories. However, you can change this behavior with the XSIApplication.Advise method.

You can also disconnect events without removing them from the cache by using the XSIApplication.Unadvise method.

Supported Events

The events that are currently supported in SOFTIMAGE|XSI appear in the following table:

Event Name

Description

OnBeginNewScene (XSIApplication)

Fired before a new scene operation is performed.

OnEndNewScene (XSIApplication)

Fired after a new scene operation was performed.

OnBeginSceneOpen (XSIApplication)

Fired before a scene open operation is performed.

OnEndSceneOpen (XSIApplication)

Fired after a scene open operation was performed.

OnBeginSceneSave (XSIApplication)

Fired before a scene save operation is performed.

OnEndSceneSave (XSIApplication)

Fired after a scene save operation was performed.

OnBeginSceneSaveAs (XSIApplication)

Fired before a scene save as operation is performed.

OnEndSceneSaveAs (XSIApplication)

Fired after a scene save as operation was performed.

OnTerminate (XSIApplication)

Fired when the XSI application terminates.

OnSelectionChange (XSIApplication)

Fired when the selection state has changed.

OnBeginFrame (XSIApplication)

Fired before a frame gets rendered.

OnEndFrame (XSIApplication)

Fired after a frame was rendered.

OnBeginSequence (XSIApplication)

Fired before a render sequence begins. This event is fired before OnBeginFrame.

OnEndSequence (XSIApplication)

Fired after a render sequence terminates. This event is fired after OnEndFrame.

OnKeyDown (XSIApplication)

The KeyDown event occurs when the user presses a key. The event will not get fired if the window with the focus handles keyboard events.

OnKeyUp (XSIApplication)

The KeyUp event occurs when the user releases a key. The event will not get fired if the window with the focus handles keyboard events.

OnBeginFileImport (XSIApplication)

Fired before an XSI file is imported.

OnEndFileImport (XSIApplication)

Fired after an XSI file is imported.

OnBeginFileExport (XSIApplication)

Fired before an XSI file is exported.

OnEndFileExport (XSIApplication)

Fired after an XSI file is exported.

 

For more information on using these events, see Events (Deprecated).

Overview of How To Use Events

How you use events in your code depends on the environment in which you are developing, of course. However, there is a basic set of steps that you need to follow that is common to most development environments:

1. Binding event handlers to event properties—see Binding Events.

2. Declare how you want to handle the event—see Declaring Event Handlers.

3. For event handlers implemented in C++, export any DLL function that you use as a handler (so that XSI can find it)—see Exporting Event Handlers.