In Tk4.0 and later, bindings are chained since it is possible for
several bindings to match a given X event. If the bindings are
associated with different tags, then each of the bindings will be
executed, in order. By default, a class binding will be executed
first, followed by a binding for the widget, a binding for its
toplevel, and an all binding. The bindtags command may
be used to change this order for a particular window or to associate
additional binding tags with the window (see corresponding help page
for details). If the result of closure in the bindings chain is the symbol
break, the next closures of the chain are not executed. The example below
illustrates this:
Bindings for the entry .e are executed before those for its class (i.e. Entry). This allows us to filter the characters which are effectively passed to the .e widget. The test in this binding closure breaks the chain of bindings if the typed character is not a digit. Otherwise, the following binding, the one for the Entry class, is executed and inserts the character typed (a digit). Consequently, the simple previous binding makes .e a controlled entry which only accepts integer numbers.