Example 8.2, “Event Handler”, shows how the generated code for a window specific event handler may look like. The Tcl/Tk command »bind« adds an event handler to a set.
The Inspector context menu presents the following scripts:
%W %W %x %y;# widget (x,y)-pos %W %x %y %X %Y;# widget rel+abs (x,y)-pos %W %s %x %y;# widget -state (x,y)-pos %W %A;# widget key code
Prefer the %W place holder notation over window path names, when designing an event handler. Using window path names inside of event handlers requires to encapsulate the event handler either with list or subst . An explanation for list and subst was given in Property Encapsulation.
The Tcl-command »break« has a special meaning inside of an event handler. »break« terminates the processing of the current event. That is: no other event handler inside a later set is evaluated. See Example 8.3, “break inside Events”. The bindtags list determines the sequence in which event handler sets are evaluated; direction is from left to right.