---
name: "gk_event"
section: "3gk"
platform: "linux"
package: "groupkit"
version: "3.2-1"
release: "Debian 1.3 (Bo)"
platforms: ["linux"]
url: "https://new.carta.tech/gk_event"
---

# gk\_event(3gk)

generating and dealing with events

## NAME

gk\_on, gk\_event, gk\_postEvent -  generating and dealing with events

## SYNOPSIS

- **gk\_postEvent** *event*

  - **gk\_on** *pattern action*

  - **gk\_event** *attribute*

  ## DESCRIPTION

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\_postEvent** *event*

  Post an event specified by the keyed list *event*.  This must include an attribute **type** which specifies the type of the  event; other attributes are dependent on this type.  This will invoke all existing triggers (see **gk\_on** below).

- **gk\_on** *pattern action*

  Create a new event trigger.  When an event is generated (see  **gk\_postEvent** above), 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.

## SEE ALSO

gk\_newenv(n), gk\_notifier(n)

## AUTHOR

Mark Roseman (roseman@cpsc.ucalgary.ca)
