Reference

gk_notifier(3gk)

create a bind like mechanism for general notifications

NAME

gk_notifier - create a bind like mechanism for general notifications

SYNOPSIS

gk_notifier name

DESCRIPTION

The gk_notifier command creates a new gk_notifier object. A notification object provides the same type of functionality as Tk's bind command -- attaching callbacks to events -- but generalizes the notion away from X11 events. Users of the gk_notifier object can both generate arbitrary events, as well as bind callbacks to arbitrary events. Multiple gk_notifier objects can exist in an application, and multiple bind callbacks can fire on a single event.

Events consist of two parts: an event type and a list of event attributes. In general, all events of the same type will have the same attributes, though the specific values of the attributes may differ. Attributes are specified when the event is generated, and can be retrieved via substitutions in event bindings.

The gk_notifier command creates a Tcl command which is used to access the created gk_notifier object. If the name of the object is specified as "-anonymous", the gk_notifier command will assign a name. The name of the gk_notifier object is returned.

GK_NOTIFIER OBJECT COMMAND

The gk_notifier command creates a new Tcl command whose name is name. This command may be used to invoke various operations on the gk_notifier object. The following operations are allowed:

name notify type attributes

Generate an event of type type. The event attributes are specified by attributes, which is a list of pair. The first element of each pair is a single character used to refer to the attribute in bindings. The second element of each pair is the value of the attribute.

name bind type handler

Create a new binding for events having type type. When an event of that type is generated, the Tcl script specified in handler is invoked. The handler is first searched for any percent signs, which flag event substitutions. For each percent sign, the character after the percent sign is examined. If it matches one of the event attribute characters specified when the event was generated, the corresponding value of the attribute from the event is substituted. Two special cases exist: the string "%%" is used to specify a single percent sign, and the string "%E" is substituted with the event type. The command returns an identifier for the binding, which can be used to later remove the binding with the delete subcommand.

name delete binding

Delete a binding previously created using the bind subcommand. The binding parameter is the name of the binding to delete, returned from bind.

name destroy

Destroy the gk_notifier object and its Tcl command.

EXAMPLE

gk_notifier announce
announce bind someEvent "doEvent %U %R %E"
proc doEvent {usernum roomname event} {
  puts "u->$usernum r->$roomname e->$event"
}
announce notify someEvent [list [list U 25] [list R Foyer]]

NOTE

Currently, bindings are fired in the order they are created. Future versions may include a "-before" option on the bind subcommand, to insert the new binding relative to other bindings.

AUTHOR

Mark Roseman ([email protected])