Debian Codegraph @

pod/pTk/BindTable.pod

raw
1 # Copyright (c) 1994 The Regents of the University of California.
2 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
3 # See the file "license.terms" for information on usage and redistribution
4 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
5 #
6 #
7
8 =head1 NAME
9
10 Tk_CreateBindingTable, Tk_DeleteBindingTable, Tk_CreateBinding, Tk_DeleteBinding, Tk_GetBinding, Tk_GetAllBindings, Tk_DeleteAllBindings, Tk_BindEvent - invoke scripts in response to X events
11
12 =for category C Programming
13
14 =head1 SYNOPSIS
15
16 B<#include E<lt>tk.hE<gt>>
17
18 Tk_BindingTable
19 B<Tk_CreateBindingTable(>I<interp>B<)>
20
21 B<Tk_DeleteBindingTable(>I<bindingTable>B<)>
22
23 unsigned long
24 B<Tk_CreateBinding(>I<interp, bindingTable, object, eventString, script, append>B<)>
25
26 int
27 B<Tk_DeleteBinding(>I<interp, bindingTable, object, eventString>B<)>
28
29 char *
30 B<Tk_GetBinding(>I<interp, bindingTable, object, eventString>B<)>
31
32 B<Tk_GetAllBindings(>I<interp, bindingTable, object>B<)>
33
34 B<Tk_DeleteAllBindings(>I<bindingTable, object>B<)>
35
36 B<Tk_BindEvent(>I<bindingTable, eventPtr, tkwin, numObjects, objectPtr>B<)>
37
38 =head1 ARGUMENTS
39
40 =over 4
41
42 =item Tcl_Interp *interp (in)
43
44 Interpreter to use when invoking bindings in binding table. Also
45 used for returning results and errors from binding procedures.
46
47 =item Tk_BindingTable bindingTable (in)
48
49 Token for binding table; must have been returned by some previous
50 call to B<Tk_CreateBindingTable>.
51
52 =item ClientData object (in)
53
54 Identifies object with which binding is associated.
55
56 =item char *eventString (in)
57
58 String describing event sequence.
59
60 =item char *script (in)
61
62 Callback to invoke when binding triggers.
63
64 =item int append (in)
65
66 Non-zero means append I<script> to existing script for binding,
67 if any; zero means replace existing script with new one.
68
69 =item XEvent *eventPtr (in)
70
71 X event to match against bindings in I<bindingTable>.
72
73 =item Tk_Window tkwin (in)
74
75 Identifier for any window on the display where the event occurred.
76 Used to find display-related information such as key maps.
77
78 =item int numObjects (in)
79
80 Number of object identifiers pointed to by I<objectPtr>.
81
82 =item ClientData *objectPtr (in)
83
84 Points to an array of object identifiers: bindings will be considered
85 for each of these objects in order from first to last.
86
87 =back
88
89 =head1 DESCRIPTION
90
91 These procedures provide a general-purpose mechanism for creating
92 and invoking bindings.
93 Bindings are organized in terms of I<binding tables>.
94 A binding table consists of a collection of bindings plus a history
95 of recent events.
96 Within a binding table, bindings are associated with I<objects>.
97 The meaning of an object is defined by clients of the binding package.
98 For example, Tk keeps uses one binding table to hold all of the bindings
99 created by the B<bind> command.
100 For this table, objects are pointers to strings such as window names, class
101 names, or other binding tags such as B<all>.
102 Tk also keeps a separate binding table for each canvas widget, which manages
103 bindings created by the canvas's B<bind> method; within
104 this table, an object is either a pointer to the internal structure for a
105 canvas item or a Tk_Uid identifying a tag.
106
107 The procedure B<Tk_CreateBindingTable> creates a new binding
108 table and associates I<interp> with it (when bindings in the
109 table are invoked, the scripts will be evaluated in I<interp>).
110 B<Tk_CreateBindingTable> returns a token for the table, which
111 must be used in calls to other procedures such as B<Tk_CreateBinding>
112 or B<Tk_BindEvent>.
113
114 B<Tk_DeleteBindingTable> frees all of the state associated
115 with a binding table.
116 Once it returns the caller should not use the I<bindingTable>
117 token again.
118
119 B<Tk_CreateBinding> adds a new binding to an existing table.
120 The I<object> argument identifies the object with which the
121 binding is to be associated, and it may be any one-word value.
122 Typically it is a pointer to a string or data structure.
123 The I<eventString> argument identifies the event or sequence
124 of events for the binding; see the documentation for the
125 B<bind> command for a description of its format.
126 I<script> is the Callback to be evaluated when the binding
127 triggers.
128 I<append> indicates what to do if there already
129 exists a binding for I<object> and I<eventString>: if I<append>
130 is zero then I<script> replaces the old script; if I<append>
131 is non-zero then the new script is appended to the old one.
132 B<Tk_CreateBinding> returns an X event mask for all the events
133 associated with the bindings.
134 This information may be useful to invoke B<XSelectInput> to
135 select relevant events, or to disallow the use of certain events
136 in bindings.
137 If an error occurred while creating the binding (e.g., I<eventString>
138 refers to a non-existent event), then 0 is returned and an error
139 message is left in I<interp-E<gt>result>.
140
141 B<Tk_DeleteBinding> removes from I<bindingTable> the
142 binding given by I<object> and I<eventString>, if
143 such a binding exists.
144 B<Tk_DeleteBinding> always returns TCL_OK.
145 In some cases it may reset I<interp-E<gt>result> to the default
146 empty value.
147
148 B<Tk_GetBinding> returns a pointer to the script associated
149 with I<eventString> and I<object> in I<bindingTable>.
150 If no such binding exists then NULL is returned and an error
151 message is left in I<interp-E<gt>result>.
152
153 B<Tk_GetAllBindings> returns in I<interp-E<gt>result> a list
154 of all the event strings for which there are bindings in
155 I<bindingTable> associated with I<object>.
156 If there are no bindings for I<object> then an empty
157 string is returned in I<interp-E<gt>result>.
158
159 B<Tk_DeleteAllBindings> deletes all of the bindings in
160 I<bindingTable> that are associated with I<object>.
161
162 B<Tk_BindEvent> is called to process an event.
163 It makes a copy of the event in an internal history list associated
164 with the binding table, then it checks for bindings that match
165 the event.
166 B<Tk_BindEvent> processes each of the objects pointed to
167 by I<objectPtr> in turn.
168 For each object, it finds all the bindings that match the current
169 event history, selects the most specific binding using the priority
170 mechanism described in the documentation for B<bind>,
171 and invokes the script for that binding.
172 If there are no matching bindings for a particular object, then
173 the object is skipped.
174 B<Tk_BindEvent> continues through all of the objects, handling
175 exceptions such as errors, B<break>, and B<continue> as
176 described in the documentation for B<bind>.
177
178 =head1 KEYWORDS
179
180 binding, event, object, script