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
15

DESCRIPTION

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

EXAMPLE

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

SEE ALSO

81       bind(n)
82
83

KEYWORDS

85       binding, event, tag
86
87
88
89Tk                                    4.0                          bindtags(n)
Impressum