Name
hw_RunEventCallback -- run event user callback (V6.1)
Synopsis
int error = hw_RunEventCallback(lua_State *L, int type, APTR userdata);
Function
This function runs the user callback associated with the event specified in type. This must be an event handler that has been registered using either the hw_RegisterEventHandler() or hw_RegisterEventHandlerEx() function. The userdata you have to pass to this function is the same you would pass to hw_PostEvent() or hw_PostEventEx(). See hw_PostEvent for details.

Normally, you should leave the execution of event user callbacks to Hollywood, i.e. you should just call hw_PostEvent() or hw_PostEventEx() when an event occurs and Hollywood will run the appropriate user callbacks whenever the script runs Hollywood's WaitEvent() or CheckEvent() command. However, there might be situations in which you'd like to run event callbacks immediately instead of in the next event cycle, e.g. if you're running a modal loop or something. In that case, hw_RunEventCallback() can be used to instantly run the user callback.

Note that you need to take care to call this function at a reasonable time. hw_RunEventCallback() will immediately call lua_pcall() so it must be called at a time when the Hollywood script expects to be interrupted by a user callback. For example, calling hw_RunEventCallback() in HandleEvents() when HWHEFLAGS_LINEHOOK is set is a bad idea because it can result in all sorts of unwanted behaviour since in that case user event callbacks might be entered after every single line of code that the Lua VM has executed. The best place to call hw_RunEventCallback() is when Hollywood is in a modal loop or in a WaitEvent() state.

Designer compatibility
Unsupported

Inputs
L
pointer to the lua_State
type
event handler type registered through hw_RegisterEventHandler() or hw_RegisterEventHandlerEx()
userdata
user data to pass to the event handler
Results
error
error code or 0 for success

Show TOC