Version 0 of Behavior of break for text tag bindings

Updated 2002-12-27 02:06:35

The break command in a text widget tag binding does not prevent widget and class level bindings from firing. See the c.l.t discussion at [L1 ].

Here is a session that shows break doesn't stop the widget and class bindings from firing:

 % text .t
 .t
 % pack .t
 % .t insert 1.0 "some text" jump
 % bind Text <1> "puts Text"
 % bind .t <1> "puts .t"
 % .t tag bind jump <1> "puts {jump tag}; break"
 % # Now click on the text
 jump tag
 .t
 Text

This behavior is undesirable in cases where the text tag binding changes some state (such as the insertion cursor location) and then the Text class binding changes the same state, thereby undoing what the tag binding did.

One workaround is to add an entry to the binding chain before the Text class that will execute break if the event happened at an index containing the text tag. The following shows how to block the Text class binding for a mouse button-1 event that happens on a text tag called myTextTag:

 bind mySpecialBindings <1> {if {[lsearch [%W tag names @%x,%y] myTextTag] >= 0} break}
 bindtags .t {.t mySpecialBindings Text . all}