gk_event3gk
Generating and dealing with events
Usage
gk_postEventevent
- gk_on pattern action
- gk_event attribute
Overview
These commands provide a way to generate and receive events, which are used as a notification mechanism throughout GroupKit. Events consist of a set of attribute/value pairs. All events include the type attribute which identifies it; other attributes depend on this type.
Applications arrange to be notified when an event occurs by specifying a trigger. Triggers consist of a pattern and an action; the pattern is a Tcl expression which determines if the application is interested in the event, and the action is a Tcl expression that is executed if the pattern returns true.
Commands
gk_postEventevent-
Post an event specified by the keyed list event. This must include an attribute
typewhich specifies the type of the event; other attributes are dependent on this type. This will invoke all existing triggers (seegk_onbelow).
- gk_on pattern action
-
Create a new event trigger. When an event is generated (see
gk_postEventabove), the Tcl code specified in pattern is evaluated. If the result is a true value, the Tcl code in action is executed.
- gk_event attribute
-
Return the value associated with attribute of the current event. This is commonly used in triggers. It is only valid to call this during the "scope" of an event.
Debugging
If the "debugevents" key of the "userprefs" environment is set to 1 (i.e. in the user's .groupkitrc file), the contents of each generated event will be displayed on stdout.
Note
In the future, this mechanism will likely change somewhat to be more similar to Tk's bind mechanism. In particular, the concept of pattern will likely be replaced by just the event type, leaving further decisions on whether to process the event to be handled in the event handler (action) itself. Additionally, certain types of events (such as for environments) will be bound to particular objects, rather than all events being global in scope.
Releases
Unchanged in 2 releases since Debian 1.2 (Rex).