1bindtags(n)                  Tk Built-In Commands                  bindtags(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       bindtags  -  Determine  which  bindings apply to a window, and order of
9       evaluation
10

SYNOPSIS

12       bindtags window ?tagList?
13______________________________________________________________________________
14

DESCRIPTION

16       When a binding is created with  the  bind  command,  it  is  associated
17       either  with  a  particular window such as .a.b.c, a class name such as
18       Button, the keyword all, or any other string.  All of these  forms  are
19       called  binding tags.  Each window contains a list of binding tags that
20       determine how events are processed  for  the  window.   When  an  event
21       occurs  in  a  window,  it  is  applied to each of the window's tags in
22       order:  for each tag, the most specific binding that matches the  given
23       tag  and  event is executed.  See the bind command for more information
24       on the matching process.
25
26       By default, each window has four binding tags consisting of the name of
27       the  window,  the window's class name, the name of the window's nearest
28       toplevel ancestor, and all, in that order.  Toplevel windows have  only
29       three  tags  by default, since the toplevel name is the same as that of
30       the window.  The bindtags command allows the binding tags for a  window
31       to be read and modified.
32
33       If  bindtags is invoked with only one argument, then the current set of
34       binding tags for window is returned as a list.  If the tagList argument
35       is  specified  to bindtags, then it must be a proper list; the tags for
36       window are changed to the  elements  of  the  list.   The  elements  of
37       tagList may be arbitrary strings;  however, any tag starting with a dot
38       is treated as the name of a window;  if no window by that  name  exists
39       at  the  time  an  event is processed, then the tag is ignored for that
40       event.  The order of the elements in tagList determines  the  order  in
41       which binding scripts are executed in response to events.  For example,
42       the command
43              bindtags .b {all . Button .b}
44       reverses the order in which binding scripts will  be  evaluated  for  a
45       button  named  .b  so that all bindings are invoked first, following by
46       bindings for .b's toplevel (“.”), followed by class bindings,  followed
47       by  bindings for .b.  If tagList is an empty list then the binding tags
48       for window are returned to the default state described above.
49
50       The bindtags command may be  used  to  introduce  arbitrary  additional
51       binding  tags  for  a window, or to remove standard tags.  For example,
52       the command
53              bindtags .b {.b TrickyButton . all}
54       replaces the Button tag for .b with TrickyButton.  This means that  the
55       default widget bindings for buttons, which are associated with the But‐
56       ton tag, will no longer apply to .b, but any bindings  associated  with
57       TrickyButton (perhaps some new button behavior) will apply.
58

EXAMPLE

60       If you have a set of nested frame widgets and you want events sent to a
61       button widget to also be delivered to all the widgets up to the current
62       toplevel  (in  contrast  to Tk's default behavior, where events are not
63       delivered to those intermediate windows) to  make  it  easier  to  have
64       accelerators that are only active for part of a window, you could use a
65       helper procedure like this to help set things up:
66              proc setupBindtagsForTreeDelivery {widget} {
67                  set tags [list $widget [winfo class $widget]]
68                  set w $widget
69                  set t [winfo toplevel $w]
70                  while {$w ne $t} {
71                      set w [winfo parent $w]
72                      lappend tags $w
73                  }
74                  lappend tags all
75                  bindtags $widget $tags
76              }
77

SEE ALSO

79       bind(n)
80

KEYWORDS

82       binding, event, tag
83
84
85
86Tk                                    4.0                          bindtags(n)
Impressum