1bindtags(3)           User Contributed Perl Documentation          bindtags(3)
2
3
4

NAME

6       Tk::bindtags - Determine which bindings apply to a window, and order of
7       evaluation
8

SYNOPSIS

10       $widget->bindtags([tagList]);
11
12       @tags = $widget->bindtags;
13

DESCRIPTION

15       When a binding is created with the bind command, it is associated
16       either with a particular window such as $widget, a class name such as
17       Tk::Button, the keyword all, or any other string.  All of these forms
18       are called binding tags.  Each window has a list of binding tags that
19       determine how events are processed for the window.  When an event
20       occurs in a window, it is applied to each of the window's tags in
21       order:  for each tag, the most specific binding that matches the given
22       tag and event is executed.  See the Tk::bind documentation for more
23       information on the matching process.
24
25       By default, each window has four binding tags consisting of the the
26       window's class name, name of the window, the name of the window's near‐
27       est toplevel ancestor, and all, in that order.  Toplevel windows have
28       only three tags by default, since the toplevel name is the same as that
29       of the window.
30
31       Note that this order is different from order used by Tcl/Tk.  Tcl/Tk
32       has the window ahead of the class name in the binding order.  This is
33       because Tcl is procedural rather than object oriented and the normal
34       way for Tcl/Tk applications to override class bindings is with an
35       instance binding. However, with perl/Tk the normal way to override a
36       class binding is to derive a class. The perl/Tk order causes instance
37       bindings to execute after the class binding, and so instance bind call‐
38       backs can make use of state changes (e.g. changes to the selection)
39       than the class bindings have made.
40
41       The bindtags command allows the binding tags for a window to be read
42       and modified.
43
44       If $widget->bindtags is invoked without an argument, then the current
45       set of binding tags for $widget is returned as a list.  If the tagList
46       argument is specified to bindtags, then it must be a reference to and
47       array; the tags for $widget are changed to the elements of the array.
48       (A reference to an anonymous array can be created by enclosin the ele‐
49       ments in [ ].)  The elements of tagList may be arbitrary strings or
50       widget objects, if no window exists for an object at the time an event
51       is processed, then the tag is ignored for that event.  The order of the
52       elements in tagList determines the order in which binding callbacks are
53       executed in response to events.  For example, the command
54
55        $b->bindtags([$b,ref($b),$b->toplevel,'all'])
56
57       applies the Tcl/Tk binding order which binding callbacks will be evalu‐
58       ated for a button (say) $b so that $b's instance bindings are invoked
59       first, following by bindings for $b's class, followed by bindings for
60       $b's toplevel, followed by 'all' bindings.
61
62       If tagList is an empty list i.e. [], then the binding tags for $widget
63       are returned to the perl/Tk default state described above.
64
65       The bindtags command may be used to introduce arbitrary additional
66       binding tags for a window, or to remove standard tags.  For example,
67       the command
68
69        $b->bindtags(['TrickyButton',$b->toplevel,'all'])
70
71       replaces the (say) Tk::Button tag for $b with TrickyButton.  This means
72       that the default widget bindings for buttons, which are associated with
73       the Tk::Button tag, will no longer apply to $b, but any bindings asso‐
74       ciated with TrickyButton (perhaps some new button behavior) will apply.
75

BUGS

77       The current mapping of the 'native' Tk behaviour of this method i.e.
78       returning a list but only accepting a reference to an array is counter
79       intuitive. The perl/Tk interface  may be tidied up, returning a list is
80       sensible so, most likely fix will be to allow a list to be passed to
81       /fIset/fR the bindtags.
82

SEE ALSO

84       Tk::bind Tk::callbacks
85

KEYWORDS

87       binding, event, tag
88
89
90
91perl v5.8.8                       2008-02-05                       bindtags(3)
Impressum