beetlebug▾
/

bindtags

Gives or sets the list of binding tags of a widget, in the order that its events use them.

bindtags WINDOW ?TAGLIST?

Description

An event of a widget runs the bindings of each tag of its list, from the first tag to the last. break in a binding script stops the later tags. With no TAGLIST, bindtags gives the list.

The default list has four tags: the widget, its class, its toplevel, and all. A toplevel has three, because it is its own toplevel. The class of . is the name of the application with a capital first letter, such as Ztk.

TAGLIST replaces the list. A tag can be any word, so a script can give a group of widgets the bindings of one tag. An empty TAGLIST sets the default list again.

Returns

The list of tags, or an empty string when TAGLIST is given.

Examples

% button .b
> bindtags .b
.b Button . all

% toplevel .t
> bindtags .t
.t Toplevel all

% bindtags .b {Shortcut .b}
> bindtags .b
Shortcut .b

# An empty list sets the default list again.
% bindtags .b {}
> bindtags .b
.b Button . all

# The tag Special is first in the list, so its binding runs first.
% frame .h -width 10 -height 10
> pack .h
> update
> bindtags .h {Special .h}
> bind Special <1> {lappend ::order special}
> bind .h <1> {lappend ::order widget}
> set ::order {}
> event generate .h <1>
> set order
special widget

Errors

% bindtags
wrong # args: should be "bindtags window ?taglist?"
-errorcode TCL WRONGARGS

% bindtags .nope
bad window path name ".nope"
-errorcode NONE

% bindtags .b "a \{"
unmatched open brace in list
-errorcode TCL VALUE LIST BRACE

Differences from Tcl

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also