1bind(n) Tk Built-In Commands bind(n)
2
3
4
5______________________________________________________________________________
6
8 bind - Arrange for X events to invoke Tcl scripts
9
11 bind tag ?sequence? ?+??script?
12_________________________________________________________________
13
15 The bind command associates Tcl scripts with X events. If all three
16 arguments are specified, bind will arrange for script (a Tcl script) to
17 be evaluated whenever the event(s) given by sequence occur in the win‐
18 dow(s) identified by tag. If script is prefixed with a “+”, then it is
19 appended to any existing binding for sequence; otherwise script
20 replaces any existing binding. If script is an empty string then the
21 current binding for sequence is destroyed, leaving sequence unbound.
22 In all of the cases where a script argument is provided, bind returns
23 an empty string.
24
25 If sequence is specified without a script, then the script currently
26 bound to sequence is returned, or an empty string is returned if there
27 is no binding for sequence. If neither sequence nor script is speci‐
28 fied, then the return value is a list whose elements are all the
29 sequences for which there exist bindings for tag.
30
31 The tag argument determines which window(s) the binding applies to. If
32 tag begins with a dot, as in .a.b.c, then it must be the path name for
33 a window; otherwise it may be an arbitrary string. Each window has an
34 associated list of tags, and a binding applies to a particular window
35 if its tag is among those specified for the window. Although the bind‐
36 tags command may be used to assign an arbitrary set of binding tags to
37 a window, the default binding tags provide the following behavior:
38
39 · If a tag is the name of an internal window the binding applies to
40 that window.
41
42 · If the tag is the name of a toplevel window the binding applies to
43 the toplevel window and all its internal windows.
44
45 · If the tag is the name of a class of widgets, such as Button, the
46 binding applies to all widgets in that class;
47
48 · If tag has the value all, the binding applies to all windows in the
49 application.
50
52 The sequence argument specifies a sequence of one or more event pat‐
53 terns, with optional white space between the patterns. Each event pat‐
54 tern may take one of three forms. In the simplest case it is a single
55 printing ASCII character, such as a or [. The character may not be a
56 space character or the character <. This form of pattern matches a
57 KeyPress event for the particular character. The second form of pat‐
58 tern is longer but more general. It has the following syntax:
59 <modifier-modifier-type-detail>
60 The entire event pattern is surrounded by angle brackets. Inside the
61 angle brackets are zero or more modifiers, an event type, and an extra
62 piece of information (detail) identifying a particular button or
63 keysym. Any of the fields may be omitted, as long as at least one of
64 type and detail is present. The fields must be separated by white
65 space or dashes.
66
67 The third form of pattern is used to specify a user-defined, named vir‐
68 tual event. It has the following syntax:
69 <<name>>
70 The entire virtual event pattern is surrounded by double angle brack‐
71 ets. Inside the angle brackets is the user-defined name of the virtual
72 event. Modifiers, such as Shift or Control, may not be combined with a
73 virtual event to modify it. Bindings on a virtual event may be created
74 before the virtual event is defined, and if the definition of a virtual
75 event changes dynamically, all windows bound to that virtual event will
76 respond immediately to the new definition.
77
78 Some widgets (e.g. menu and text) issue virtual events when their
79 internal state is updated in some ways. Please see the manual page for
80 each widget for details.
81
82 MODIFIERS
83 Modifiers consist of any of the following values: Con‐
84 trol Mod1, M1, Command Alt Mod2,
85 M2, Option Shift Mod3, M3
86 Lock Mod4, M4 Extended Mod5, M5 But‐
87 ton1, B1 Meta, M Button2, B2 Double Button3,
88 B3 Triple Button4, B4 Quadruple Button5, B5
89 Where more than one value is listed, separated by commas, the values
90 are equivalent. Most of the modifiers have the obvious X meanings.
91 For example, Button1 requires that button 1 be depressed when the event
92 occurs. For a binding to match a given event, the modifiers in the
93 event must include all of those specified in the event pattern. An
94 event may also contain additional modifiers not specified in the bind‐
95 ing. For example, if button 1 is pressed while the shift and control
96 keys are down, the pattern <Control-Button-1> will match the event, but
97 <Mod1-Button-1> will not. If no modifiers are specified, then any com‐
98 bination of modifiers may be present in the event.
99
100 Meta and M refer to whichever of the M1 through M5 modifiers is associ‐
101 ated with the Meta key(s) on the keyboard (keysyms Meta_R and Meta_L).
102 If there are no Meta keys, or if they are not associated with any modi‐
103 fiers, then Meta and M will not match any events. Similarly, the Alt
104 modifier refers to whichever modifier is associated with the alt key(s)
105 on the keyboard (keysyms Alt_L and Alt_R).
106
107 The Double, Triple and Quadruple modifiers are a convenience for speci‐
108 fying double mouse clicks and other repeated events. They cause a par‐
109 ticular event pattern to be repeated 2, 3 or 4 times, and also place a
110 time and space requirement on the sequence: for a sequence of events to
111 match a Double, Triple or Quadruple pattern, all of the events must
112 occur close together in time and without substantial mouse motion in
113 between. For example, <Double-Button-1> is equivalent to <But‐
114 ton-1><Button-1> with the extra time and space requirement.
115
116 The Command and Option modifiers are equivalents of Mod1 resp. Mod2,
117 they correspond to Macintosh-specific modifier keys.
118
119 The Extended modifier is, at present, specific to Windows. It appears │
120 on events that are associated with the keys on the “extended keyboard”. │
121 On a US keyboard, the extended keys include the Alt and Control keys at │
122 the right of the keyboard, the cursor keys in the cluster to the left │
123 of the numeric pad, the NumLock key, the Break key, the PrintScreen │
124 key, and the / and Enter keys in the numeric keypad.
125
126 EVENT TYPES
127 The type field may be any of the standard X event types, with a few
128 extra abbreviations. The type field will also accept a couple non-
129 standard X event types that were added to better support the Macintosh
130 and Windows platforms. Below is a list of all the valid types; where
131 two names appear together, they are synonyms. Acti‐
132 vate Destroy Map ButtonPress, But‐
133 ton Enter MapRequest ButtonRe‐
134 lease Expose Motion Circu‐
135 late FocusIn MouseWheel CirculateRequest Focu‐
136 sOut Property Colormap Gravity Reparent
137 Configure KeyPress, KeyResizeRequest Configur‐
138 eRequest KeyRelease Unmap Cre‐
139 ate Leave Visibility Deactivate Most of the
140 above events have the same fields and behaviors as events in the X Win‐
141 dowing system. You can find more detailed descriptions of these events
142 in any X window programming book. A couple of the events are exten‐
143 sions to the X event system to support features unique to the Macintosh
144 and Windows platforms. We provide a little more detail on these events
145 here. These include:
146
147 Activate, Deactivate
148 These two events are sent to every sub-window of a toplevel when
149 they change state. In addition to the focus Window, the Macintosh
150 platform and Windows platforms have a notion of an active window
151 (which often has but is not required to have the focus). On the
152 Macintosh, widgets in the active window have a different appear‐
153 ance than widgets in deactive windows. The Activate event is sent
154 to all the sub-windows in a toplevel when it changes from being
155 deactive to active. Likewise, the Deactive event is sent when the
156 window's state changes from active to deactive. There are no use‐
157 ful percent substitutions you would make when binding to these
158 events.
159
160 MouseWheel
161 Many contemporary mice support a mouse wheel, which is used for
162 scrolling documents without using the scrollbars. By rolling the
163 wheel, the system will generate MouseWheel events that the appli‐
164 cation can use to scroll. Like Key events the event is always
165 routed to the window that currently has focus. When the event is
166 received you can use the %D substitution to get the delta field
167 for the event, which is a integer value describing how the mouse
168 wheel has moved. The smallest value for which the system will
169 report is defined by the OS. On Windows 95 & 98 machines this
170 value is at least 120 before it is reported. However, higher res‐
171 olution devices may be available in the future. The sign of the
172 value determines which direction your widget should scroll. Posi‐
173 tive values should scroll up and negative values should scroll
174 down.
175
176 KeyPress, KeyRelease
177 The KeyPress and KeyRelease events are generated whenever a key is
178 pressed or released. KeyPress and KeyRelease events are sent to
179 the window which currently has the keyboard focus.
180
181 ButtonPress, ButtonRelease, Motion
182 The ButtonPress and ButtonRelease events are generated when the
183 user presses or releases a mouse button. Motion events are gener‐
184 ated whenever the pointer is moved. ButtonPress, ButtonRelease,
185 and Motion events are normally sent to the window containing the
186 pointer.
187
188 When a mouse button is pressed, the window containing the pointer
189 automatically obtains a temporary pointer grab. Subsequent But‐
190 tonPress, ButtonRelease, and Motion events will be sent to that
191 window, regardless of which window contains the pointer, until all
192 buttons have been released.
193
194 Configure
195 A Configure event is sent to a window whenever its size, position,
196 or border width changes, and sometimes when it has changed posi‐
197 tion in the stacking order.
198
199 Map, Unmap
200 The Map and Unmap events are generated whenever the mapping state
201 of a window changes.
202
203 Windows are created in the unmapped state. Top-level windows
204 become mapped when they transition to the normal state, and are
205 unmapped in the withdrawn and iconic states. Other windows become
206 mapped when they are placed under control of a geometry manager
207 (for example pack or grid).
208
209 A window is viewable only if it and all of its ancestors are
210 mapped. Note that geometry managers typically do not map their
211 children until they have been mapped themselves, and unmap all
212 children when they become unmapped; hence in Tk Map and Unmap
213 events indicate whether or not a window is viewable.
214
215 Visibility
216 A window is said to be obscured when another window above it in
217 the stacking order fully or partially overlaps it. Visibility
218 events are generated whenever a window's obscurity state changes;
219 the state field (%s) specifies the new state.
220
221 Expose
222 An Expose event is generated whenever all or part of a window
223 should be redrawn (for example, when a window is first mapped or
224 if it becomes unobscured). It is normally not necessary for
225 client applications to handle Expose events, since Tk handles them
226 internally.
227
228 Destroy
229 A Destroy event is delivered to a window when it is destroyed.
230
231 When the Destroy event is delivered to a widget, it is in a “half-
232 dead” state: the widget still exists, but most operations on it
233 will fail.
234
235 FocusIn, FocusOut
236 The FocusIn and FocusOut events are generated whenever the key‐
237 board focus changes. A FocusOut event is sent to the old focus
238 window, and a FocusIn event is sent to the new one.
239
240 In addition, if the old and new focus windows do not share a com‐
241 mon parent, “virtual crossing” focus events are sent to the inter‐
242 mediate windows in the hierarchy. Thus a FocusIn event indicates
243 that the target window or one of its descendants has acquired the
244 focus, and a FocusOut event indicates that the focus has been
245 changed to a window outside the target window's hierarchy.
246
247 The keyboard focus may be changed explicitly by a call to focus,
248 or implicitly by the window manager.
249
250 Enter, Leave
251 An Enter event is sent to a window when the pointer enters that
252 window, and a Leave event is sent when the pointer leaves it.
253
254 If there is a pointer grab in effect, Enter and Leave events are
255 only delivered to the window owning the grab.
256
257 In addition, when the pointer moves between two windows, Enter and
258 Leave “virtual crossing” events are sent to intermediate windows
259 in the hierarchy in the same manner as for FocusIn and FocusOut
260 events.
261
262 Property
263 A Property event is sent to a window whenever an X property
264 belonging to that window is changed or deleted. Property events
265 are not normally delivered to Tk applications as they are handled
266 by the Tk core.
267
268 Colormap
269 A Colormap event is generated whenever the colormap associated
270 with a window has been changed, installed, or uninstalled.
271
272 Widgets may be assigned a private colormap by specifying a -col‐
273 ormap option; the window manager is responsible for installing and
274 uninstalling colormaps as necessary.
275
276 Note that Tk provides no useful details for this event type.
277
278 MapRequest, CirculateRequest, ResizeRequest, ConfigureRequest, Create
279 These events are not normally delivered to Tk applications. They
280 are included for completeness, to make it possible to write X11
281 window managers in Tk. (These events are only delivered when a
282 client has selected SubstructureRedirectMask on a window; the Tk
283 core does not use this mask.)
284
285 Gravity, Reparent, Circulate
286 The events Gravity and Reparent are not normally delivered to Tk
287 applications. They are included for completeness.
288
289 A Circulate event indicates that the window has moved to the top
290 or to the bottom of the stacking order as a result of an XCircu‐
291 lateSubwindows protocol request. Note that the stacking order may
292 be changed for other reasons which do not generate a Circulate
293 event, and that Tk does not use XCirculateSubwindows() internally.
294 This event type is included only for completeness; there is no
295 reliable way to track changes to a window's position in the stack‐
296 ing order.
297
298 EVENT DETAILS
299 The last part of a long event specification is detail. In the case of
300 a ButtonPress or ButtonRelease event, it is the number of a button
301 (1-5). If a button number is given, then only an event on that partic‐
302 ular button will match; if no button number is given, then an event on
303 any button will match. Note: giving a specific button number is dif‐
304 ferent than specifying a button modifier; in the first case, it refers
305 to a button being pressed or released, while in the second it refers to
306 some other button that is already depressed when the matching event
307 occurs. If a button number is given then type may be omitted: if will
308 default to ButtonPress. For example, the specifier <1> is equivalent
309 to <ButtonPress-1>.
310
311 If the event type is KeyPress or KeyRelease, then detail may be speci‐
312 fied in the form of an X keysym. Keysyms are textual specifications
313 for particular keys on the keyboard; they include all the alphanumeric
314 ASCII characters (e.g. “a” is the keysym for the ASCII character “a”),
315 plus descriptions for non-alphanumeric characters (“comma”is the keysym
316 for the comma character), plus descriptions for all the non-ASCII keys
317 on the keyboard (e.g. “Shift_L” is the keysym for the left shift key,
318 and “F1” is the keysym for the F1 function key, if it exists). The
319 complete list of keysyms is not presented here; it is available in
320 other X documentation and may vary from system to system. If neces‐
321 sary, you can use the %K notation described below to print out the
322 keysym name for a particular key. If a keysym detail is given, then
323 the type field may be omitted; it will default to KeyPress. For exam‐
324 ple, <Control-comma> is equivalent to <Control-KeyPress-comma>.
325
327 The script argument to bind is a Tcl script, which will be executed
328 whenever the given event sequence occurs. Command will be executed in
329 the same interpreter that the bind command was executed in, and it will
330 run at global level (only global variables will be accessible). If
331 script contains any % characters, then the script will not be executed
332 directly. Instead, a new script will be generated by replacing each %,
333 and the character following it, with information from the current
334 event. The replacement depends on the character following the %, as
335 defined in the list below. Unless otherwise indicated, the replacement
336 string is the decimal value of the given field from the current event.
337 Some of the substitutions are only valid for certain types of events;
338 if they are used for other types of events the value substituted is
339 undefined.
340
341 %% Replaced with a single percent.
342
343 %# The number of the last client request processed by the server (the
344 serial field from the event). Valid for all event types.
345
346 %a The above field from the event, formatted as a hexadecimal number.
347 Valid only for Configure events. Indicates the sibling window
348 immediately below the receiving window in the stacking order, or 0
349 if the receiving window is at the bottom.
350
351 %b The number of the button that was pressed or released. Valid only
352 for ButtonPress and ButtonRelease events.
353
354 %c The count field from the event. Valid only for Expose events.
355 Indicates that there are count pending Expose events which have
356 not yet been delivered to the window.
357
358 %d The detail or user_data field from the event. The %d is replaced │
359 by a string identifying the detail. For Enter, Leave, FocusIn,
360 and FocusOut events, the string will be one of the following:
361 NotifyAncestor NotifyNonlinearVirtual NotifyDetail‐
362 None NotifyPointer NotifyInferior NotifyPointer‐
363 Root NotifyNonlinear NotifyVirtual For ConfigureRequest
364 events, the string will be one of: Above Oppo‐
365 site Below None BottomIf TopIf │
366 For virtual events, the string will be whatever value is stored in │
367 the user_data field when the event was created (typically with │
368 event generate), or the empty string if the field is NULL. Vir‐ │
369 tual events corresponding to key sequence presses (see event add │
370 for details) set the user_data to NULL. For events other than
371 these, the substituted string is undefined.
372
373 %f The focus field from the event (0 or 1). Valid only for Enter and
374 Leave events. 1 if the receiving window is the focus window or a
375 descendant of the focus window, 0 otherwise.
376
377 %h The height field from the event. Valid for the Configure, Config‐
378 ureRequest, Create, ResizeRequest, and Expose events. Indicates
379 the new or requested height of the window.
380
381 %i The window field from the event, represented as a hexadecimal
382 integer. Valid for all event types.
383
384 %k The keycode field from the event. Valid only for KeyPress and
385 KeyRelease events.
386
387 %m The mode field from the event. The substituted string is one of
388 NotifyNormal, NotifyGrab, NotifyUngrab, or NotifyWhileGrabbed.
389 Valid only for Enter, FocusIn, FocusOut, and Leave events.
390
391 %o The override_redirect field from the event. Valid only for Map,
392 Reparent, and Configure events.
393
394 %p The place field from the event, substituted as one of the strings
395 PlaceOnTop or PlaceOnBottom. Valid only for Circulate and Circu‐
396 lateRequest events.
397
398 %s The state field from the event. For ButtonPress, ButtonRelease,
399 Enter, KeyPress, KeyRelease, Leave, and Motion events, a decimal
400 string is substituted. For Visibility, one of the strings Visi‐
401 bilityUnobscured, VisibilityPartiallyObscured, and VisibilityFul‐
402 lyObscured is substituted. For Property events, substituted with
403 either the string NewValue (indicating that the property has been
404 created or modified) or Delete (indicating that the property has
405 been removed).
406
407 %t The time field from the event. This is the X server timestamp
408 (typically the time since the last server reset) in milliseconds,
409 when the event occurred. Valid for most events.
410
411 %w The width field from the event. Indicates the new or requested
412 width of the window. Valid only for Configure, ConfigureRequest,
413 Create, ResizeRequest, and Expose events.
414
415 %x, %y
416 The x and y fields from the event. For ButtonPress, ButtonRe‐
417 lease, Motion, KeyPress, KeyRelease, and MouseWheel events, %x and
418 %y indicate the position of the mouse pointer relative to the
419 receiving window. For Enter and Leave events, the position where
420 the mouse pointer crossed the window, relative to the receiving
421 window. For Configure and Create requests, the x and y coordi‐
422 nates of the window relative to its parent window.
423
424 %A Substitutes the UNICODE character corresponding to the event, or
425 the empty string if the event does not correspond to a UNICODE
426 character (e.g. the shift key was pressed). XmbLookupString (or
427 XLookupString when input method support is turned off) does all
428 the work of translating from the event to a UNICODE character.
429 Valid only for KeyPress and KeyRelease events.
430
431 %B The border_width field from the event. Valid only for Configure,
432 ConfigureRequest, and Create events.
433
434 %D This reports the delta value of a MouseWheel event. The delta
435 value represents the rotation units the mouse wheel has been
436 moved. On Windows 95 & 98 systems the smallest value for the
437 delta is 120. Future systems may support higher resolution values
438 for the delta. The sign of the value represents the direction the
439 mouse wheel was scrolled.
440
441 %E The send_event field from the event. Valid for all event types.
442 0 indicates that this is a “normal” event, 1 indicates that it is
443 a “synthetic” event generated by SendEvent.
444
445 %K The keysym corresponding to the event, substituted as a textual
446 string. Valid only for KeyPress and KeyRelease events.
447
448 %N The keysym corresponding to the event, substituted as a decimal
449 number. Valid only for KeyPress and KeyRelease events.
450
451 %P The name of the property being updated or deleted (which may be
452 converted to an XAtom using winfo atom.) Valid only for Property
453 events.
454
455 %R The root window identifier from the event. Valid only for events
456 containing a root field.
457
458 %S The subwindow window identifier from the event, formatted as a
459 hexadecimal number. Valid only for events containing a subwindow
460 field.
461
462 %T The type field from the event. Valid for all event types.
463
464 %W The path name of the window to which the event was reported (the
465 window field from the event). Valid for all event types.
466
467 %X, %Y
468 The x_root and y_root fields from the event. If a virtual-root
469 window manager is being used then the substituted values are the
470 corresponding x-coordinate and y-coordinate in the virtual root.
471 Valid only for ButtonPress, ButtonRelease, KeyPress, KeyRelease,
472 and Motion events. Same meaning as %x and %y, except relative to
473 the (virtual) root window.
474
475 The replacement string for a %-replacement is formatted as a proper Tcl
476 list element. This means that spaces or special characters such as $
477 and { may be preceded by backslashes. This guarantees that the string
478 will be passed through the Tcl parser when the binding script is evalu‐
479 ated. Most replacements are numbers or well-defined strings such as
480 Above; for these replacements no special formatting is ever necessary.
481 The most common case where reformatting occurs is for the %A substitu‐
482 tion. For example, if script is
483 insert %A
484 and the character typed is an open square bracket, then the script
485 actually executed will be
486 insert \[
487 This will cause the insert to receive the original replacement string
488 (open square bracket) as its first argument. If the extra backslash
489 had not been added, Tcl would not have been able to parse the script
490 correctly.
491
493 It is possible for several bindings to match a given X event. If the
494 bindings are associated with different tag's, then each of the bindings
495 will be executed, in order. By default, a binding for the widget will
496 be executed first, followed by a class binding, a binding for its
497 toplevel, and an all binding. The bindtags command may be used to
498 change this order for a particular window or to associate additional
499 binding tags with the window.
500
501 The continue and break commands may be used inside a binding script to
502 control the processing of matching scripts. If continue is invoked,
503 then the current binding script is terminated but Tk will continue pro‐
504 cessing binding scripts associated with other tag's. If the break com‐
505 mand is invoked within a binding script, then that script terminates
506 and no other scripts will be invoked for the event.
507
508 If more than one binding matches a particular event and they have the
509 same tag, then the most specific binding is chosen and its script is
510 evaluated. The following tests are applied, in order, to determine
511 which of several matching sequences is more specific:
512
513 (a) an event pattern that specifies a specific button or key
514 is more specific than one that does not;
515
516 (b) a longer sequence (in terms of number of events matched)
517 is more specific than a shorter sequence;
518
519 (c) if the modifiers specified in one pattern are a subset of
520 the modifiers in another pattern, then the pattern with
521 more modifiers is more specific.
522
523 (d) a virtual event whose physical pattern matches the
524 sequence is less specific than the same physical pattern
525 that is not associated with a virtual event.
526
527 (e) given a sequence that matches two or more virtual events,
528 one of the virtual events will be chosen, but the order
529 is undefined.
530
531 If the matching sequences contain more than one event, then tests
532 (c)-(e) are applied in order from the most recent event to the least
533 recent event in the sequences. If these tests fail to determine a win‐
534 ner, then the most recently registered sequence is the winner.
535
536 If there are two (or more) virtual events that are both triggered by
537 the same sequence, and both of those virtual events are bound to the
538 same window tag, then only one of the virtual events will be triggered,
539 and it will be picked at random:
540 event add <<Paste>> <Control-y>
541 event add <<Paste>> <Button-2>
542 event add <<Scroll>> <Button-2>
543 bind Entry <<Paste>> {puts Paste}
544 bind Entry <<Scroll>> {puts Scroll}
545 If the user types Control-y, the <<Paste>> binding will be invoked, but
546 if the user presses button 2 then one of either the <<Paste>> or the
547 <<Scroll>> bindings will be invoked, but exactly which one gets invoked
548 is undefined.
549
550 If an X event does not match any of the existing bindings, then the
551 event is ignored. An unbound event is not considered to be an error.
552
554 When a sequence specified in a bind command contains more than one
555 event pattern, then its script is executed whenever the recent events
556 (leading up to and including the current event) match the given
557 sequence. This means, for example, that if button 1 is clicked repeat‐
558 edly the sequence <Double-ButtonPress-1> will match each button press
559 but the first. If extraneous events that would prevent a match occur
560 in the middle of an event sequence then the extraneous events are
561 ignored unless they are KeyPress or ButtonPress events. For example,
562 <Double-ButtonPress-1> will match a sequence of presses of button 1,
563 even though there will be ButtonRelease events (and possibly Motion
564 events) between the ButtonPress events. Furthermore, a KeyPress event
565 may be preceded by any number of other KeyPress events for modifier
566 keys without the modifier keys preventing a match. For example, the
567 event sequence aB will match a press of the a key, a release of the a
568 key, a press of the Shift key, and a press of the b key: the press of
569 Shift is ignored because it is a modifier key. Finally, if several
570 Motion events occur in a row, only the last one is used for purposes of
571 matching binding sequences.
572
574 If an error occurs in executing the script for a binding then the bger‐
575 ror mechanism is used to report the error. The bgerror command will be
576 executed at global level (outside the context of any Tcl procedure).
577
579 Arrange for a string describing the motion of the mouse to be printed
580 out when the mouse is double-clicked:
581 bind . <Double-1> {
582 puts "hi from (%x,%y)"
583 }
584
585 A little GUI that displays what the keysym name of the last key pressed
586 is:
587 set keysym "Press any key"
588 pack [label .l -textvariable keysym -padx 2m -pady 1m]
589 bind . <Key> {
590 set keysym "You pressed %K"
591 }
592
594 bgerror(n), bindtags(n), event(n), focus(n), grab(n), keysyms(n)
595
597 binding, event
598
599
600
601Tk 8.0 bind(n)