Tk_CreateBindingTable, Tk_DeleteBindingTable, Tk_CreateBinding, Tk_DeleteBinding, Tk_GetBinding, Tk_GetAllBindings, Tk_DeleteAllBindings, Tk_BindEvent − invoke scripts in response to X events


#include <tk.h>



unsigned long
interp, bindingTable, object, eventString, script, append)

interp, bindingTable, object, eventString)

const char *
interp, bindingTable, object, eventString)

Tk_GetAllBindings(interp, bindingTable, object)

Tk_DeleteAllBindings(bindingTable, object)

Tk_BindEvent(bindingTable, eventPtr, tkwin, numObjects, objectPtr)


Tcl_Interp *interp (in)

Interpreter to use when invoking bindings in binding table. Also used for returning results and errors from binding procedures.

Tk_BindingTable bindingTable (in)

Token for binding table; must have been returned by some previous call to Tk_CreateBindingTable.

ClientData object (in)

Identifies object with which binding is associated.

const char *eventString (in)

String describing event sequence.

char *script (in)

Tcl script to invoke when binding triggers.

int append (in)

Non-zero means append script to existing script for binding, if any; zero means replace existing script with new one.

XEvent *eventPtr (in)

X event to match against bindings in bindingTable.

Tk_Window tkwin (in)

Identifier for any window on the display where the event occurred. Used to find display-related information such as key maps.

int numObjects (in)

Number of object identifiers pointed to by objectPtr.

ClientData *objectPtr (in)

Points to an array of object identifiers: bindings will be considered for each of these objects in order from first to last.



These procedures provide a general-purpose mechanism for creating and invoking bindings. Bindings are organized in terms of binding tables. A binding table consists of a collection of bindings plus a history of recent events. Within a binding table, bindings are associated with objects. The meaning of an object is defined by clients of the binding package. For example, Tk keeps uses one binding table to hold all of the bindings created by the bind command. For this table, objects are pointers to strings such as window names, class names, or other binding tags such as all. Tk also keeps a separate binding table for each canvas widget, which manages bindings created by the canvas’s bind widget command; within this table, an object is either a pointer to the internal structure for a canvas item or a Tk_Uid identifying a tag.

The procedure Tk_CreateBindingTable creates a new binding table and associates interp with it (when bindings in the table are invoked, the scripts will be evaluated in interp). Tk_CreateBindingTable returns a token for the table, which must be used in calls to other procedures such as Tk_CreateBinding or Tk_BindEvent.

Tk_DeleteBindingTable frees all of the state associated with a binding table. Once it returns the caller should not use the bindingTable token again.

Tk_CreateBinding adds a new binding to an existing table. The object argument identifies the object with which the binding is to be associated, and it may be any one-word value. Typically it is a pointer to a string or data structure. The eventString argument identifies the event or sequence of events for the binding; see the documentation for the bind command for a description of its format. script is the Tcl script to be evaluated when the binding triggers. append indicates what to do if there already exists a binding for object and eventString: if append is zero then script replaces the old script; if append is non-zero then the new script is appended to the old one. Tk_CreateBinding returns an X event mask for all the events associated with the bindings. This information may be useful to invoke XSelectInput to select relevant events, or to disallow the use of certain events in bindings. If an error occurred while creating the binding (e.g., eventString refers to a non-existent event), then 0 is returned and an error message is left in interp->result.

Tk_DeleteBinding removes from bindingTable the binding given by object and eventString, if such a binding exists. Tk_DeleteBinding always returns TCL_OK. In some cases it may reset interp->result to the default empty value.

Tk_GetBinding returns a pointer to the script associated with eventString and object in bindingTable. If no such binding exists then NULL is returned and an error message is left in interp->result.

Tk_GetAllBindings returns in interp->result a list of all the event strings for which there are bindings in bindingTable associated with object. If there are no bindings for object then an empty string is returned in interp->result.

Tk_DeleteAllBindings deletes all of the bindings in bindingTable that are associated with object.

Tk_BindEvent is called to process an event. It makes a copy of the event in an internal history list associated with the binding table, then it checks for bindings that match the event. Tk_BindEvent processes each of the objects pointed to by objectPtr in turn. For each object, it finds all the bindings that match the current event history, selects the most specific binding using the priority mechanism described in the documentation for bind, and invokes the script for that binding. If there are no matching bindings for a particular object, then the object is skipped. Tk_BindEvent continues through all of the objects, handling exceptions such as errors, break, and continue as described in the documentation for bind.


binding, event, object, script

More Linux Commands

timedatectl(1) Control the system time and date (Man Page)
timedatectl may be used to query and change the system clock and its settings. OPTIONS The following options are understood: --no-ask-password Do not query the

ppmglobe(1) - generate strips to glue onto a sphere.........
This program is part of Netpbm(1) ppmglobe does the inverse of a cylindrical projection of a sphere. Starting with a cylindrical projection, it produces an imag

mmap(2) - map or unmap files or devices into memory.........
mmap() creates a new mapping in the virtual address space of the calling process. The starting address for the new mapping is specified in addr. The length argu

pam_fail_delay(3) - request a delay on failure (Man Page)...
The pam_fail_delay function provides a mechanism by which an application or module can suggest a minimum delay of usec micro-seconds. The function keeps a recor

unget_wch(3ncurses) - get (or push back) a wide character fr
The get_wch, wget_wch, mvget_wch, and mvwget_wch functions read a character from the terminal associated with the current or specified window. In no-delay mode,

gzip(1) - compress or expand files - Linux manual page......
Gzip reduces the size of the named files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while keeping t

ilogbl(3) - get integer exponent of a floating-point value
These functions return the exponent part of their argument as a signed integer. When no error occurs, these functions are equivalent to the corresponding logb(3

config.guess(1) - guess the build system triplet (Man Page)
The GNU build system distinguishes three types of machines, the build machine on which the compilers are run, the host machine on which the package being built

mvinchnstr(3ncurses) - get a string of characters (and attri
These routines return a NULL-terminated array of chtype quantities, starting at the current cursor position in the named window and ending at the right margin o

Tcl_DoOneEvent(3) - wait for events and invoke event handler
This procedure is the entry point to Tcls event loop; it is responsible for waiting for events and dispatching event handlers created with procedures such as Tk

Tcl_ListObjIndex(3) - manipulate Tcl objects as lists.......
Tcl list objects have an internal representation that supports the efficient indexing and appending. The procedures described in this man page are used to creat

Tcl_GetChannelOption(3) - buffered I/O facilities using chan
The Tcl channel mechanism provides a device-independent and platform-independent mechanism for performing buffered input and output operations on a variety of f

We can't live, work or learn in freedom unless the software we use is free.