1Tk_CreateBindingTable(3)     Tk Library Procedures    Tk_CreateBindingTable(3)
2
3
4
5______________________________________________________________________________
6

NAME

8       Tk_CreateBindingTable,     Tk_DeleteBindingTable,     Tk_CreateBinding,
9       Tk_DeleteBinding, Tk_GetBinding,  Tk_GetAllBindings,  Tk_DeleteAllBind‐
10       ings, Tk_BindEvent - invoke scripts in response to X events
11

SYNOPSIS

13       #include <tk.h>
14
15       Tk_BindingTable
16       Tk_CreateBindingTable(interp)
17
18       Tk_DeleteBindingTable(bindingTable)
19
20       unsigned long
21       Tk_CreateBinding(interp, bindingTable, object, eventString, script, append)
22
23       int
24       Tk_DeleteBinding(interp, bindingTable, object, eventString)
25
26       const char *
27       Tk_GetBinding(interp, bindingTable, object, eventString)
28
29       Tk_GetAllBindings(interp, bindingTable, object)
30
31       Tk_DeleteAllBindings(bindingTable, object)
32
33       Tk_BindEvent(bindingTable, eventPtr, tkwin, numObjects, objectPtr)
34

ARGUMENTS

36       Tcl_Interp *interp (in)                    Interpreter   to   use  when
37                                                  invoking bindings in binding
38                                                  table.     Also   used   for
39                                                  returning results and errors
40                                                  from binding procedures.
41
42       Tk_BindingTable bindingTable (in)          Token   for  binding  table;
43                                                  must have been  returned  by
44                                                  some    previous   call   to
45                                                  Tk_CreateBindingTable.
46
47       ClientData object (in)                     Identifies object with which
48                                                  binding is associated.
49
50       const char *eventString (in)               String    describing   event
51                                                  sequence.
52
53       char *script (in)                          Tcl script  to  invoke  when
54                                                  binding triggers.
55
56       int append (in)                            Non-zero means append script
57                                                  to existing script for bind‐
58                                                  ing,   if  any;  zero  means
59                                                  replace existing script with
60                                                  new one.
61
62       XEvent *eventPtr (in)                      X  event  to  match  against
63                                                  bindings in bindingTable.
64
65       Tk_Window tkwin (in)                       Identifier for any window on
66                                                  the  display where the event
67                                                  occurred.  Used to find dis‐
68                                                  play-related     information
69                                                  such as key maps.
70
71       int numObjects (in)                        Number of object identifiers
72                                                  pointed to by objectPtr.
73
74       ClientData *objectPtr (in)                 Points to an array of object
75                                                  identifiers:  bindings  will
76                                                  be  considered  for  each of
77                                                  these objects in order  from
78                                                  first to last.
79_________________________________________________________________
80
81

DESCRIPTION

83       These  procedures  provide a general-purpose mechanism for creating and
84       invoking bindings.  Bindings are organized in terms of binding  tables.
85       A  binding table consists of a collection of bindings plus a history of
86       recent events.  Within a binding table, bindings  are  associated  with
87       objects.  The meaning of an object is defined by clients of the binding
88       package.  For example, Tk keeps uses one binding table to hold  all  of
89       the  bindings created by the bind command.  For this table, objects are
90       pointers to strings such as window names, class names, or other binding
91       tags such as all.  Tk also keeps a separate binding table for each can‐
92       vas widget, which manages bindings created by the canvas's bind  widget
93       command;   within  this  table,  an  object  is either a pointer to the
94       internal structure for a canvas item or a Tk_Uid identifying a tag.
95
96       The procedure Tk_CreateBindingTable creates a new binding table and as‐
97       sociates  interp  with  it (when bindings in the table are invoked, the
98       scripts will be evaluated in interp).  Tk_CreateBindingTable returns  a
99       token  for  the  table, which must be used in calls to other procedures
100       such as Tk_CreateBinding or Tk_BindEvent.
101
102       Tk_DeleteBindingTable frees all of the state associated with a  binding
103       table.   Once  it  returns  the  caller should not use the bindingTable
104       token again.
105
106       Tk_CreateBinding adds a new binding to an existing table.   The  object
107       argument  identifies the object with which the binding is to be associ‐
108       ated, and it may be any one-word value.  Typically it is a pointer to a
109       string  or  data  structure.   The  eventString argument identifies the
110       event or sequence of events for the binding;  see the documentation for
111       the  bind  command  for a description of its format.  script is the Tcl
112       script to be evaluated when the  binding  triggers.   append  indicates
113       what   to  do  if  there  already  exists  a  binding  for  object  and
114       eventString:  if append is zero then script replaces  the  old  script;
115       if  append  is non-zero then the new script is appended to the old one.
116       Tk_CreateBinding returns an X event mask for all the events  associated
117       with the bindings.  This information may be useful to invoke XSelectIn‐
118       put to select relevant events, or to disallow the use of certain events
119       in  bindings.   If  an error occurred while creating the binding (e.g.,
120       eventString refers to a non-existent event), then 0 is returned and  an
121       error message is left in interp->result.
122
123       Tk_DeleteBinding  removes from bindingTable the binding given by object
124       and eventString, if such a  binding  exists.   Tk_DeleteBinding  always
125       returns  TCL_OK.   In  some  cases  it  may reset interp->result to the
126       default empty value.
127
128       Tk_GetBinding  returns  a  pointer  to  the  script   associated   with
129       eventString and object in bindingTable.  If no such binding exists then
130       NULL is returned and an error message is left in interp->result.
131
132       Tk_GetAllBindings returns in interp->result a list  of  all  the  event
133       strings  for  which  there are bindings in bindingTable associated with
134       object.  If there are no bindings for object then an  empty  string  is
135       returned in interp->result.
136
137       Tk_DeleteAllBindings  deletes  all of the bindings in bindingTable that
138       are associated with object.
139
140       Tk_BindEvent is called to process an event.  It makes  a  copy  of  the
141       event  in  an  internal history list associated with the binding table,
142       then it checks for bindings that match the  event.   Tk_BindEvent  pro‐
143       cesses  each  of the objects pointed to by objectPtr in turn.  For each
144       object, it finds all the bindings that match the current event history,
145       selects   the  most  specific  binding  using  the  priority  mechanism
146       described in the documentation for bind, and  invokes  the  script  for
147       that  binding.   If  there  are  no  matching bindings for a particular
148       object, then the object is skipped.  Tk_BindEvent continues through all
149       of the objects, handling exceptions such as errors, break, and continue
150       as described in the documentation for bind.
151
152

KEYWORDS

154       binding, event, object, script
155
156
157
158Tk                                    4.0             Tk_CreateBindingTable(3)
Impressum