Name
hw_RegisterCallback -- register a new callback (V5.2)
Synopsis
APTR cb = hw_RegisterCallback(int type, APTR func, APTR userdata);
Function
This function can be used to register a new callback that will be run by Hollywood in a certain context which is specified by type. The following callback types are currently supported:

HWCB_AMIGASIGNAL:
This is only supported in the AmigaOS compatible versions of Hollywood. Hollywood will run callbacks of the type HWCB_AMIGASIGNAL whenever it is about to call exec.library/Wait() to wait on a set of signals. Your callback will then be asked for additional signal bits that should be included in the call to Wait(). The prototype for an Amiga signal callback looks like this:

 
ULONG AmigaSignal(APTR userdata);

Hollywood will pass the user data that you pass in parameter 3 of hw_RegisterCallback() to your AmigaSignal() callback. Your AmigaSignal() callback has to return a combination of signal bits that should be included in the call to Wait(). There are two special return values: If you return 0, Hollywood will run your AmigaSignal() again. If you return 0xFFFFFFFF, no additional signals will be included in the call to Wait(). If your callback needs to return an error code to Hollywood, you have to use HWMCP_SETAMIGASIGNALERROR for that. See hw_MasterControl for details.

HWCB_LINEHOOK:
Callbacks of type HWCB_LINEHOOK will be run whenever Hollywood runs its line hook, i.e. after running one line of Lua code. Line hooks are called very often, usually many times per second. Thus, you must make sure that your line hook callback doesn't do any expensive things or it will slow down the script's execution significantly. The prototype for a line hook callback looks like this:

 
int LineHook(lua_State *L, APTR userdata);

Your line hook callback will receive a pointer to the lua_State as well as the user data that has been passed to hw_RegisterCallback() when registering the callback. Your callback has to return a standard Hollywood error code or 0 for success. (V6.0)

HWCB_SHOWHIDEAPP:
This is only supported in the AmigaOS compatible versions of Hollywood. Hollywood will run callbacks of type HWCB_SHOWHIDEAPP whenever the user changes the visibility of an application via commodities' Exchange tool or application.library on AmigaOS4. The prototype for a show/hide app callback looks like this:

 
void ShowHideApp(int show, APTR userdata);

When the application is shown, Hollywood will pass True in the show parameter and when the application is hidden, this parameter will be set to False. (V6.1)

HWCB_ENCODINGCHANGE:
Callbacks of type HWCB_ENCODINGCHANGE will be run whenever the encoding of the current script changes. This can only happen once for each script. Since all scripts run in UTF-8 encoding by default starting in Hollywood 7.0, the only change that you can be notified of through this callback is an encoding change from UTF-8 to ISO 8859-1. This can only happen if a script explicitly requests ISO 8859-1 to run in compatibility mode. Normally, all scripts should run in UTF-8 encoding starting with Hollywood 7.0. The prototype for an encoding change callback looks like this:

 
void EncodingChange(int encoding, APTR userdata);

The encoding parameter will contain the new encoding. As described above, this can only ever be HWOS_ENCODING_ISO8859_1 since the default encoding is HWOS_ENCODING_UTF8. Note that there is also a hw_GetEncoding() function to get the current encoding but this is not so convenient because the script encoding hasn't been set yet when the plugin is initialized. See hw_GetEncoding for details. (V7.0)

HWCB_DROPFILECHANGE:
Callbacks of type HWCB_DROPFILECHANGE will be run whenever the user installs or deinstalls a listener on the "OnDropFile" event handler using Hollywood's InstallEventHandler() function. This is especially useful for display adapters which want to support drag'n'drop through Hollywood's standard event handlers and need to take some action whenever the user enables or disables drag'n'drop by installing or removing a listener on the "OnDropFile" event handler. The prototype for a drop file change callback looks like this:

 
void DropFileChange(APTR d, int enable, APTR userdata);

The callback will receive a pointer to the display for which drag'n'drop should be enabled or disabled in the d parameter and either True or False in the enable parameter. (V7.0)

Designer compatibility
Supported since Designer 5.0

Inputs
type
callback type to register (see above for supported types)
func
pointer to callback function; the actual format of this function depends on the specified callback type (see above)
userdata
user data that should be passed to the callback function when Hollywood runs it
Results
cb
callback handle or NULL on error

Show TOC