Introduction

The tk/bind command associates lambda-expressions with X events. If all three arguments are specified, tk/bind will arrange for lambda-expression to be evaluated whenever the event(s) given by sequence occur in the window(s) identified by tag.

If lambda-expression has no arguments, it can be noted as (lambda () ...).

If lambda-expression has arguments delivered by the event, e. g. %W for the invoking window, the lambda-expression can be noted inside a list as `(,(lambda (w) ...) %W).

Previous arranged bindings are replaced by lambda-expression. If you want not to remove them but just add your actual expression, use the form `(+ ,(lambda () ...)) or `(+ ,(lambda (w) ...) %W).

If lambda-expression is () string then the current binding for sequence is destroyed, leaving sequence unbound. In all of the cases where a lambda-expression argument is provided, bind returns an empty string.

If sequence is specified without a lambda-expression, then the lambda-expression currently bound to sequence is returned, or () is returned if there is no binding for sequence.

If neither sequence nor script is specified, then the return value is a list whose elements are all the sequences for which there exist bindings for tag.

The tag argument determines which window(s) the binding applies to. It may be an existing widget, e. g. tk, or an arbitrary symbol. Each window has an associated list of tags, and a binding applies to a particular window if its tag is among those specified for the window. Although the tk/bindtags command may be used to assign an arbitrary set of binding tags to a window, the default binding tags provide the following behavior:

  1. If a tag is an internal window the binding applies to that window.
  2. If the tag is a toplevel window the binding applies to the toplevel window and all its internal windows.
  3. If the tag is the name of a class of widgets, such as Button, the binding applies to all widgets in that class;
  4. If tag has the value all, the binding applies to all windows in the application.

© Author | Home | Sitemap