Advanced Search
Mail us
Home    Manuel    Links    Faq    Submit a tcl/tk Reference    Contact Us

    Some examples tcl/tk codes     Man of Bwidget     Man of blt     mkwidget screenshots     TkOgl     Video Demo real.

  How can I add new actions to an existing binding?
 The binding model in Tk4 allows you to have bindings trigger for a
widget instance without modifying that of the widget`s class.  The
following example sets a global variable to the item which a user
selects in a listbox without interfering with Tk`s highlighting of that

bind .listbox  { set my_global [%W get [%W nearest %y]] }

If you want your binding on the widget instance to be the only event to
trigger (avoiding any possible class or all binding), then add a `break`
at the end of the binding, like so:

bind .listbox  { destroy %W; break }

If you still want to add to an existing binding, you need to have a `+`
on the first line of the bind command, like so:

bind .listbox  {+ destroy %W; break }

See the documentation for `bind` and `bindtags` for more information.