stk/Help/bindtags.n.html

65 lines
3.5 KiB
HTML

<HTML><HEAD><TITLE>Tk Built-In Commands - bindtags manual page</TITLE></HEAD>
<BR>
<BODY bgcolor = #c3c3ff>
<H2><IMG ALIGN=BOTTOM SRC="./Img/ManPageBlue.gif"> bindtags</H2>
<I>Determine which bindings apply to a window, and order of evaluation</I><P><IMG ALIGN=TOP SRC="./Img/line-red.gif">
<H3><A NAME="M2">SYNOPSIS</A></H3>
(<B>bindtags </B><I>window </I>?<I>tagList</I>?)<BR>
<H3><A NAME="M3">DESCRIPTION</A></H3>
When a binding is created with the <B><A HREF="./bind.n.html">bind</A></B> procedure, it is
associated either with a particular window such as <B>.a.b.c</B>,
a class name such as <B><A HREF="./button.n.html">Button</A></B>, the constant <B>&quot;all&quot;</B>, or any
other string.
All of these forms are called <I>binding tags</I>.
Each window contains a list of binding tags that determine how
events are processed for the window.
When an event occurs in a window, it is applied to each of the
window's tags in order: for each tag, the most specific binding
that matches the given tag and event is executed.
See the <B><A HREF="./bind.n.html">bind</A></B> procedure for more information on the matching
process.
<P>
By default, each window has four binding tags consisting of the
name of the window, the window's class name, the name of the window's
nearest toplevel ancestor, and <B>&quot;all&quot;</B>, in that order.
Toplevel windows have only three tags by default, since the toplevel
name is the same as that of the window.
The <B>bindtags</B> procedure allows the binding tags for a window to be
read and modified.
<P>
If <B>bindtags</B> is invoked with only one argument, then the
current set of binding tags for <I>window</I> is returned as a list.
If the <I>tagList</I> argument is specified to <B>bindtags</B>,
then it must be a proper list; the tags for <I>window</I> are changed
to the elements of the list.
The elements of <I>tagList</I> may be arbitrary strings; however,
any tag starting with a dot is treated as the name of a window; if
no window by that name exists at the time an event is processed,
then the tag is ignored for that event.
The order of the elements in <I>tagList</I> determines the order in
which binding scripts are executed in response to events.
For example, the call
<PRE><B>(bindtags .b '(&quot;all&quot; *root* &quot;Button&quot; .b))</B></PRE>
reverses the order in which binding scripts will be evaluated for
a button named <B>.b</B> so that <B>&quot;all&quot;</B> bindings are invoked
first, following by bindings for <B>.b</B>'s toplevel (<B>*root</B>* or ``.''),
followed by class bindings, followed by bindings for <B>.b</B>.
If <I>tagList</I> is an empty list then the binding tags for <I>window</I>
are returned to the default state described above.
<P>
The <B>bindtags</B> procedure may be used to introduce arbitrary
additional binding tags for a window, or to remove standard tags.
For example,
<PRE><B>(bindtags .b '(.b &quot;TrickyButton&quot; *root* &quot;all&quot;})</B></PRE>
replaces the <B><A HREF="./button.n.html">Button</A></B> tag for <B>.b</B> with <B>TrickyButton</B>.
This means that the default widget bindings for buttons, which are
associated with the <B><A HREF="./button.n.html">Button</A></B> tag, will no longer apply to <B>.b</B>,
but any bindings associated with <B>TrickyButton</B> (perhaps some
new button behavior) will apply.
<H3><A NAME="M4">SEE ALSO</A></H3>
<B><A HREF="./bind.n.html">bind</A></B>
<P><IMG ALIGN=TOP SRC="./Img/line-red.gif"><P>
<A HREF=./STk-hlp.html><IMG ALIGN=BOTTOM SRC="./Img/RefBookBlue.gif"> Back to the <B>STk</B> main page</A>
</BODY></HTML>