Programmer Guide/Macro Library/SETMSGHANDLER: Difference between revisions

From STX Wiki
Jump to navigationJump to search
Line 13: Line 13:


;type:The item type of sender; any shell item type (sending messages) or <code>SHELL</code>
;type:The item type of sender; any shell item type (sending messages) or <code>SHELL</code>
;name:The name of the sender; shell item name, shell id or <code>*</code> for all items of the specified type <var>type</var>.handlerThe message handler function. This function will be called when a message for an item corresponding to <var>type</var> and <var>name</var> is received. If <var>handler</var> is not supplied, any previously installed message handler for <var>type name</var> is removed. The handler function can be either a macro (<var>handler</var> = macroname) or a class member-function (<var>handler</var> = memberfunction instance). The following keywords are also supported: <code>IGNORE</code> (all messages for <var>type</var> <var>name</var> are ignored) and <code>RETURN</code> (return from <code>GETMESSAGE</code> if a message for <var>type</var> <var>name</var> is received). If the <var>type</var> is <code>SPU</code>,the following keywords are also supported: <code>KILLSPUONSTOP</code> (the SPU is deleted when the <code>STOP</code> message is received) and <code>KILLSPUONEXIT</code> (the SPU is deleted when the <code>EXIT</code> message is received). The message handler function receives the whole message (<code>type name id par</code>) as an argument string.
;name:The name of the sender; shell item name, shell id or <code>*</code> for all items of the specified type <var>type</var>.
;handler:The message handler function. This function will be called when a message for an item corresponding to <var>type</var> and <var>name</var> is received. If <var>handler</var> is not supplied, any previously installed message handler for <var>type name</var> is removed. The handler function can be either a macro (<var>handler</var> = macroname) or a class member-function (<var>handler</var> = memberfunction instance). The following keywords are also supported: <code>IGNORE</code> (all messages for <var>type</var> <var>name</var> are ignored) and <code>RETURN</code> (return from <code>GETMESSAGE</code> if a message for <var>type</var> <var>name</var> is received). If the <var>type</var> is <code>SPU</code>,the following keywords are also supported: <code>KILLSPUONSTOP</code> (the SPU is deleted when the <code>STOP</code> message is received) and <code>KILLSPUONEXIT</code> (the SPU is deleted when the <code>EXIT</code> message is received). The message handler function receives the whole message (<code>type name id par</code>) as an argument string.


=====Result:=====
=====Result:=====

Revision as of 11:43, 14 June 2019

SETMSGHANDLER

Install the message handler handler for the sender(s) defined by type name. If no handler is supplied, the message handler is deinstalled. If a message handler is installed for type name, the macro GETMESSAGE calls the handler function when receiving messages of type name. This means the messages are not returned (except if the keyword RETURN was used as a handler argument). A message handler function receives the whole message (type name id par) as an argument string.

The message dispatching system is only active while the macro GETMESSAGE is running!

Usage:

SETMSGHANDLER type name [handler]

Parameters:
type
The item type of sender; any shell item type (sending messages) or SHELL
name
The name of the sender; shell item name, shell id or * for all items of the specified type type.
handler
The message handler function. This function will be called when a message for an item corresponding to type and name is received. If handler is not supplied, any previously installed message handler for type name is removed. The handler function can be either a macro (handler = macroname) or a class member-function (handler = memberfunction instance). The following keywords are also supported: IGNORE (all messages for type name are ignored) and RETURN (return from GETMESSAGE if a message for type name is received). If the type is SPU,the following keywords are also supported: KILLSPUONSTOP (the SPU is deleted when the STOP message is received) and KILLSPUONEXIT (the SPU is deleted when the EXIT message is received). The message handler function receives the whole message (type name id par) as an argument string.
Result:

void

Examples:
// Any messages for value items are passed to the macro MH_VALUEITEM.
SETMSGHANDLER VALUE * MH_VALUEITEM

Navigation menu

Personal tools