EVB::CallbackManager -- Object that manages callback sets.


EVB::CallbackManager name

name define callback-name

name register callback-name script

name get callback-name

name invoke callback-name substitutions values


Manages a set of callbacks. This can be used by megawidgets and supports script substitution patterns.

The conceptual idea is that the application instantiates a callback manager and uses define to define callbacks. As callback scripts are supplied they are inserted into the callback manager using register. When it is time to run a callback, invoke allows you to do so specifying a set of substition keys and the values to substitute for those keys in the script.

invoke runs callbacks at level 0 using uplevel #0.

When constructing a manager, supply a single parameter that provides a name for the callback manager object. The special name %AUTO% allocates a unique name for the object for you. Construction returns the name of the object. The following idiom is therefore best used when using %AUTO%:

set cbManager [EVB::CallbackManager %AUTO%]
$cbManager define mycallback;    # e.g.


define callback-name

Defines a callback. Clients can only register callback scripts for callbacks that have been defined via this method. Furthermore, only define callbacks can be invoked without an error being thrown. Callbacks have names (callback-name).

register callback-name script

Registers a script for the callback callback-name.

If script is empty, the callback is assumed to have no script.

get callback-name

Returns the script that is registered on the callback-name. If there is no script registered, an empty string is returned.

invoke callback-name substitutions values

Invokes the callback registered on callback-name. If the registered script is empty, this is a no-op. Prior to executing the script, all occurences of the strings in the list substitutions are replaced by corresponcing elements in the list values

This mechanism allows callers to supply information to the callback as desired by that callback.