1mNAME0m
       bind - Arrange for X events to invoke Tcl scripts

1mSYNOPSIS0m
       1mbind 4m22mtag24m ?4msequence24m? ?1m+22m??4mscript24m?


1mINTRODUCTION0m
       The  1mbind  22mcommand  associates Tcl scripts with X events.  If all three
       arguments are specified, 1mbind 22mwill arrange for 4mscript24m (a Tcl script) to
       be  evaluated whenever the event(s) given by 4msequence24m occur in the win-
       dow(s) identified by 4mtag24m.  If 4mscript24m is prefixed with a ``+'', then  it
       is  appended  to  any  existing binding for 4msequence24m;  otherwise 4mscript0m
       replaces any existing binding.  If 4mscript24m is an empty string  then  the
       current  binding  for  4msequence24m is destroyed, leaving 4msequence24m unbound.
       In all of the cases where a 4mscript24m argument is provided,  1mbind  22mreturns
       an empty string.

       If  4msequence24m  is  specified without a 4mscript24m, then the script currently
       bound to 4msequence24m is returned, or an empty string is returned if  there
       is  no  binding for 4msequence24m.  If neither 4msequence24m nor 4mscript24m is speci-
       fied, then the return value is  a  list  whose  elements  are  all  the
       sequences for which there exist bindings for 4mtag24m.

       The 4mtag24m argument determines which window(s) the binding applies to.  If
       4mtag24m begins with a dot, as in 1m.a.b.c22m, then it must be the path name  for
       a  window; otherwise it may be an arbitrary string.  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 1mbind-0m
       1mtags 22mcommand may be used to assign an arbitrary set of binding tags  to
       a window, the default binding tags provide the following behavior:

       o  If  a  tag  is the name of an internal window the binding applies to
          that window.

       o  If the tag is the name of a toplevel window the binding  applies  to
          the toplevel window and all its internal windows.

       o  If  the  tag  is the name of a class of widgets, such as 1mButton22m, the
          binding applies to all widgets in that class;

       o  If 4mtag24m has the value 1mall22m, the binding applies to all windows in  the
          application.

1mEVENT PATTERNS0m
       The  4msequence24m  argument  specifies a sequence of one or more event pat-
       terns, with optional white space between the patterns.  Each event pat-
       tern  may take one of three forms.  In the simplest case it is a single
       printing ASCII character, such as 1ma 22mor 1m[22m.  The character may not  be  a
       space  character  or  the  character 1m<22m.  This form of pattern matches a
       1mKeyPress 22mevent for the particular character.  The second form  of  pat-
       tern is longer but more general.  It has the following syntax:
              1m<4m22mmodifier-modifier-type-detail24m1m>0m
       The  entire  event pattern is surrounded by angle brackets.  Inside the
       angle brackets are zero or more modifiers, an event type, and an  extra
       piece  of  information  (4mdetail24m)  identifying  a  particular  button or
       keysym.  Any of the fields may be omitted, as long as at least  one  of
       4mtype24m  and  4mdetail24m  is  present.   The fields must be separated by white
       space or dashes.

       The third form of pattern is used to specify a user-defined, named vir-
       tual event.  It has the following syntax:
              1m<<4m22mname24m1m>>0m
       The  entire  virtual event pattern is surrounded by double angle brack-
       ets.  Inside the angle brackets is the user-defined name of the virtual
       event.  Modifiers, such as 1mShift 22mor 1mControl22m, may not be combined with a
       virtual event to modify it.  Bindings on a virtual event may be created
       before the virtual event is defined, and if the definition of a virtual
       event changes dynamically, all windows bound to that virtual event will
       respond immediately to the new definition.

       Some  widgets  (e.g.  1mmenu  22mand  1mtext22m)  issue virtual events when their
       internal state is updated in some ways.  Please see the manual page for
       each widget for details.

1mMODIFIERS0m
       Modifiers consist of any of the following values:

              1mControl                 Mod2, M20m
              1mShift                   Mod3, M30m
              1mLock                    Mod4, M40m
              1mButton1, B1             Mod5, M50m
              1mButton2, B2             Meta, M0m
              1mButton3, B3             Alt0m
              1mButton4, B4             Double0m
              1mButton5, B5             Triple0m
              1mMod1, M1                Quadruple0m

       Where  more  than  one value is listed, separated by commas, the values
       are equivalent.  Most of the modifiers have  the  obvious  X  meanings.
       For example, 1mButton1 22mrequires that button 1 be depressed when the event
       occurs.  For a binding to match a given event,  the  modifiers  in  the
       event  must  include  all  of those specified in the event pattern.  An
       event may also contain additional modifiers not specified in the  bind-
       ing.   For  example, if button 1 is pressed while the shift and control
       keys are down, the pattern 1m<Control-Button-1> 22mwill match the event, but
       1m<Mod1-Button-1> 22mwill not.  If no modifiers are specified, then any com-
       bination of modifiers may be present in the event.

       1mMeta 22mand 1mM 22mrefer to whichever of the 1mM1 22mthrough 1mM5 22mmodifiers is associ-
       ated  with the Meta key(s) on the keyboard (keysyms 1mMeta_R 22mand 1mMeta_L22m).
       If there are no Meta keys, or if they are not associated with any modi-
       fiers,  then  1mMeta 22mand 1mM 22mwill not match any events.  Similarly, the 1mAlt0m
       modifier refers to whichever modifier is associated with the alt key(s)
       on the keyboard (keysyms 1mAlt_L 22mand 1mAlt_R22m).

       The 1mDouble22m, 1mTriple 22mand 1mQuadruple 22mmodifiers are a convenience for speci-
       fying double mouse clicks and other repeated events. They cause a  par-
       ticular  event pattern to be repeated 2, 3 or 4 times, and also place a
       time and space requirement on the sequence: for a sequence of events to
       match  a  1mDouble22m,  1mTriple  22mor 1mQuadruple 22mpattern, all of the events must
       occur close together in time and without substantial  mouse  motion  in
       between.    For  example,  1m<Double-Button-1>  22mis  equivalent  to  1m<But-0m
       1mton-1><Button-1> 22mwith the extra time and space requirement.


1mEVENT TYPES0m
       The 4mtype24m field may be any of the standard X event  types,  with  a  few
       extra  abbreviations.   The  4mtype24m  field will also accept a couple non-
       standard X event types that were added to better support the  Macintosh
       and  Windows  platforms.  Below is a list of all the valid types; where
       two names appear together, they are synonyms.

              1mActivate              Destroy         Map0m
              1mButtonPress, Button   Enter           MapRequest0m
              1mButtonRelease         Expose          Motion0m
              1mCirculate             FocusIn         MouseWheel0m
              1mCirculateRequest      FocusOut        Property0m
              1mColormap              Gravity         Reparent0m
              1mConfigure             KeyPress, Key   ResizeRequest0m
              1mConfigureRequest      KeyRelease      Unmap0m
              1mCreate                Leave           Visibility0m
              1mDeactivate0m

       Most of the above events have the same fields and behaviors  as  events
       in  the X Windowing system.  You can find more detailed descriptions of
       these events in any X window programming book.  A couple of the  events
       are  extensions to the X event system to support features unique to the
       Macintosh and Windows platforms.  We provide a little  more  detail  on
       these events here.  These include:

       1mActivate22m, 1mDeactivate0m
            These  two  events are sent to every sub-window of a toplevel when
            they change state.  In addition to the focus Window, the Macintosh
            platform  and  Windows platforms have a notion of an active window
            (which often has but is not required to have the focus).   On  the
            Macintosh,  widgets  in the active window have a different appear-
            ance than widgets in deactive windows.  The 1mActivate 22mevent is sent
            to  all  the  sub-windows in a toplevel when it changes from being
            deactive to active.  Likewise, the 1mDeactive 22mevent is sent when the
            window's state changes from active to deactive.  There are no use-
            ful percent substitutions you would make  when  binding  to  these
            events.

       1mMouseWheel0m
            Some  mice  on the Windows platform support a mouse wheel which is
            used for scrolling documents without  using  the  scrollbars.   By
            rolling the wheel, the system will generate 1mMouseWheel 22mevents that
            the application can use to  scroll.   On  Windows,  the  event  is
            always  routed  to  the  window that currently has focus (like 1mKey0m
            events.) On Mac OS X, the event is routed to the window under  the
            pointer.   When the event is received you can use the 1m%D 22msubstitu-
            tion to get the 4mdelta24m field for the  event,  which  is  a  integer
            value  describing  how  the  mouse  wheel has moved.  The smallest
            value for which the system will report is defined by the  OS.   On
            Windows  95  & 98 machines this value is at least 120 before it is
            reported.  However, higher resolution devices may be available  in
            the  future.   On  Mac OS X, the value is not scaled by 120, but a
            value of 1 corresponds to roughly one text line.  The sign of  the
            value determines which direction your widget should scroll.  Posi-
            tive values should scroll up and  negative  values  should  scroll
            down.

       1mKeyPress22m, 1mKeyRelease0m
            The 1mKeyPress 22mand 1mKeyRelease 22mevents are generated whenever a key is
            pressed or released.  1mKeyPress 22mand 1mKeyRelease 22mevents are  sent  to
            the window which currently has the keyboard focus.

       1mButtonPress22m, 1mButtonRelease22m, 1mMotion0m
            The  1mButtonPress  22mand  1mButtonRelease 22mevents are generated when the
            user presses or releases a mouse button.  1mMotion 22mevents are gener-
            ated  whenever  the pointer is moved.  1mButtonPress22m, 1mButtonRelease22m,
            and 1mMotion 22mevents are normally sent to the window  containing  the
            pointer.

            When  a mouse button is pressed, the window containing the pointer
            automatically obtains a temporary pointer grab.   Subsequent  1mBut-0m
            1mtonPress22m,  1mButtonRelease22m,  and  1mMotion 22mevents will be sent to that
            window, regardless of which window contains the pointer, until all
            buttons have been released.

       1mConfigure0m
            A 1mConfigure 22mevent is sent to a window whenever its size, position,
            or border width changes, and sometimes when it has  changed  posi-
            tion in the stacking order.

       1mMap22m, 1mUnmap0m
            The  1mMap 22mand 1mUnmap 22mevents are generated whenever the mapping state
            of a window changes.

            Windows are created in  the  unmapped  state.   Top-level  windows
            become  mapped  when  they transition to the 1mnormal 22mstate, and are
            unmapped in the 1mwithdrawn 22mand 1miconic 22mstates.  Other windows become
            mapped  when  they  are placed under control of a geometry manager
            (for example 1mpack 22mor 1mgrid22m).

            A window is 4mviewable24m only if it  and  all  of  its  ancestors  are
            mapped.   Note  that  geometry managers typically do not map their
            children until they have been mapped  themselves,  and  unmap  all
            children  when  they  become  unmapped;  hence in Tk 1mMap 22mand 1mUnmap0m
            events indicate whether or not a window is viewable.

       1mVisibility0m
            A window is said to be 4mobscured24m when another window  above  it  in
            the  stacking  order  fully  or partially overlaps it.  1mVisibility0m
            events are generated whenever a window's obscurity state  changes;
            the 4mstate24m field (1m%s22m) specifies the new state.

       1mExpose0m
            An  1mExpose  22mevent  is  generated  whenever all or part of a window
            should be redrawn (for example, when a window is first  mapped  or
            if  it  becomes  unobscured).   It  is  normally not necessary for
            client applications to handle 1mExpose 22mevents, since Tk handles them
            internally.

       1mDestroy0m
            A 1mDestroy 22mevent is delivered to a window when it is destroyed.

            When  the  1mDestroy  22mevent  is  delivered  to  a widget, it is in a
            ``half-dead'' state: the widget still exists, but most  operations
            on it will fail.

       1mFocusIn22m, 1mFocusOut0m
            The  1mFocusIn  22mand  1mFocusOut 22mevents are generated whenever the key-
            board focus changes.  A 1mFocusOut 22mevent is sent to  the  old  focus
            window, and a 1mFocusIn 22mevent is sent to the new one.

            In  addition, if the old and new focus windows do not share a com-
            mon parent, ``virtual crossing'' focus  events  are  sent  to  the
            intermediate windows in the hierarchy.  Thus a 1mFocusIn 22mevent indi-
            cates that the  target  window  or  one  of  its  descendants  has
            acquired  the focus, and a 1mFocusOut 22mevent indicates that the focus
            has been changed to a window outside the target  window's  hierar-
            chy.

            The  keyboard  focus may be changed explicitly by a call to 1mfocus22m,
            or implicitly by the window manager.

       1mEnter22m, 1mLeave0m
            An 1mEnter 22mevent is sent to a window when the  pointer  enters  that
            window, and a 1mLeave 22mevent is sent when the pointer leaves it.

            If  there  is a pointer grab in effect, 1mEnter 22mand 1mLeave 22mevents are
            only delivered to the window owning the grab.

            In addition, when the pointer moves between two windows, 1mEnter 22mand
            1mLeave 22m``virtual crossing'' events are sent to intermediate windows
            in the hierarchy in the same manner as for  1mFocusIn  22mand  1mFocusOut0m
            events.

       1mProperty0m
            A  1mProperty  22mevent  is  sent  to  a  window whenever an X property
            belonging to that window is changed or deleted.   1mProperty  22mevents
            are  not normally delivered to Tk applications as they are handled
            by the Tk core.

       1mColormap0m
            A 1mColormap 22mevent is generated  whenever  the  colormap  associated
            with a window has been changed, installed, or uninstalled.

            Widgets  may  be assigned a private colormap by specifying a 1m-col-0m
            1mormap 22moption; the window manager is responsible for installing and
            uninstalling colormaps as necessary.

            Note that Tk provides no useful details for this event type.

       1mMapRequest22m, 1mCirculateRequest22m, 1mResizeRequest22m, 1mConfigureRequest22m, 1mCreate0m
            These  events are not normally delivered to Tk applications.  They
            are included for completeness, to make it possible  to  write  X11
            window  managers  in  Tk.  (These events are only delivered when a
            client has selected 1mSubstructureRedirectMask 22mon a window;  the  Tk
            core does not use this mask.)

       1mGravity22m, 1mReparent22m, 1mCirculate0m
            The  events  1mGravity 22mand 1mReparent 22mare not normally delivered to Tk
            applications.  They are included for completeness.

            A 1mCirculate 22mevent indicates that the window has moved to  the  top
            or  to  the bottom of the stacking order as a result of an 1mXCircu-0m
            1mlateSubwindows 22mprotocol request.  Note that the stacking order may
            be  changed  for  other  reasons which do not generate a 1mCirculate0m
            event, and that Tk does not use 1mXCirculateSubwindows() 22minternally.
            This  event  type  is  included only for completeness; there is no
            reliable way to track changes to a window's position in the stack-
            ing order.

1mEVENT DETAILS0m
       The  last part of a long event specification is 4mdetail24m.  In the case of
       a 1mButtonPress 22mor 1mButtonRelease 22mevent, it is  the  number  of  a  button
       (1-5).  If a button number is given, then only an event on that partic-
       ular button will match;  if no button number is given, then an event on
       any  button will match.  Note:  giving a specific button number is dif-
       ferent than specifying a button modifier; in the first case, it  refers
       to a button being pressed or released, while in the second it refers to
       some other button that is already depressed  when  the  matching  event
       occurs.  If a button number is given then 4mtype24m may be omitted:  if will
       default to 1mButtonPress22m.  For example, the specifier 1m<1>  22mis  equivalent
       to 1m<ButtonPress-1>22m.

       If  the event type is 1mKeyPress 22mor 1mKeyRelease22m, then 4mdetail24m may be speci-
       fied in the form of an X keysym.  Keysyms  are  textual  specifications
       for  particular keys on the keyboard; they include all the alphanumeric
       ASCII characters (e.g. ``a'' is the  keysym  for  the  ASCII  character
       ``a''), plus descriptions for non-alphanumeric characters (``comma'' is
       the keysym for the comma character), plus descriptions for all the non-
       ASCII  keys  on  the  keyboard  (``Shift_L'' is the keysym for the left
       shift key, and ``F1'' is the keysym for the  F1  function  key,  if  it
       exists).   The  complete  list of keysyms is not presented here;  it is
       available in other X documentation and may vary from system to  system.
       If  necessary, you can use the 1m%K 22mnotation described below to print out
       the keysym name for a particular key.  If a  keysym  4mdetail24m  is  given,
       then  the 4mtype24m field may be omitted;  it will default to 1mKeyPress22m.  For
       example, 1m<Control-comma> 22mis equivalent to 1m<Control-KeyPress-comma>22m.

1mBINDING SCRIPTS AND SUBSTITUTIONS0m
       The 4mscript24m argument to 1mbind 22mis a Tcl script,  which  will  be  executed
       whenever  the given event sequence occurs.  4mCommand24m will be executed in
       the same interpreter that the 1mbind 22mcommand was executed in, and it will
       run  at  global  level  (only global variables will be accessible).  If
       4mscript24m contains any 1m% 22mcharacters, then the script will not be  executed
       directly.  Instead, a new script will be generated by replacing each 1m%22m,
       and the character following  it,  with  information  from  the  current
       event.   The  replacement  depends on the character following the 1m%22m, as
       defined in the list below.  Unless otherwise indicated, the replacement
       string  is the decimal value of the given field from the current event.
       Some of the substitutions are only valid for certain types  of  events;
       if  they  are  used  for other types of events the value substituted is
       undefined.

       1m%%   22mReplaced with a single percent.

       1m%#   22mThe number of the last client request processed by the server (the
            4mserial24m field from the event).  Valid for all event types.

       1m%a   22mThe 4mabove24m field from the event, formatted as a hexadecimal number.
            Valid only for 1mConfigure 22mevents.   Indicates  the  sibling  window
            immediately below the receiving window in the stacking order, or 1m00m
            if the receiving window is at the bottom.

       1m%b   22mThe number of the button that was pressed or released.  Valid only
            for 1mButtonPress 22mand 1mButtonRelease 22mevents.

       1m%c   22mThe  4mcount24m  field  from  the event.  Valid only for 1mExpose 22mevents.
            Indicates that there are 4mcount24m pending 1mExpose  22mevents  which  have
            not yet been delivered to the window.

       1m%d   22mThe  4mdetail24m  field from the event.  The 1m%d 22mis replaced by a string
            identifying the detail.  For 1mEnter22m, 1mLeave22m, 1mFocusIn22m,  and  1mFocusOut0m
            events, the string will be one of the following:

                   1mNotifyAncestor          NotifyNonlinearVirtual0m
                   1mNotifyDetailNone        NotifyPointer0m
                   1mNotifyInferior          NotifyPointerRoot0m
                   1mNotifyNonlinear         NotifyVirtual0m

            For 1mConfigureRequest 22mevents, the string will be one of:

                   1mAbove                   Opposite0m
                   1mBelow                   None0m
                   1mBottomIf                TopIf0m

            For  events other than these, the substituted string is undefined.

       1m%f   22mThe 4mfocus24m field from the event (1m0 22mor 1m122m).  Valid only for 1mEnter 22mand
            1mLeave  22mevents.  1m1 22mif the receiving window is the focus window or a
            descendant of the focus window, 1m0 22motherwise.

       1m%h   22mThe 4mheight24m field from the event.  Valid for the 1mConfigure22m, 1mConfig-0m
            1mureRequest22m,  1mCreate22m,  1mResizeRequest22m, and 1mExpose 22mevents.  Indicates
            the new or requested height of the window.

       1m%i   22mThe 4mwindow24m field from the  event,  represented  as  a  hexadecimal
            integer.  Valid for all event types.

       1m%k   22mThe  4mkeycode24m  field  from  the event.  Valid only for 1mKeyPress 22mand
            1mKeyRelease 22mevents.

       1m%m   22mThe 4mmode24m field from the event.  The substituted string is  one  of
            1mNotifyNormal22m,  1mNotifyGrab22m,  1mNotifyUngrab22m,  or  1mNotifyWhileGrabbed22m.
            Valid only for 1mEnter22m, 1mFocusIn22m, 1mFocusOut22m, and 1mLeave 22mevents.

       1m%o   22mThe 4moverride_redirect24m field from the event.  Valid only  for  1mMap22m,
            1mReparent22m, and 1mConfigure 22mevents.

       1m%p   22mThe  4mplace24m field from the event, substituted as one of the strings
            1mPlaceOnTop 22mor 1mPlaceOnBottom22m.  Valid only for 1mCirculate 22mand  1mCircu-0m
            1mlateRequest 22mevents.

       1m%s   22mThe  4mstate24m  field from the event.  For 1mButtonPress22m, 1mButtonRelease22m,
            1mEnter22m, 1mKeyPress22m, 1mKeyRelease22m, 1mLeave22m, and 1mMotion 22mevents,  a  decimal
            string  is  substituted.  For 1mVisibility22m, one of the strings 1mVisi-0m
            1mbilityUnobscured22m, 1mVisibilityPartiallyObscured22m, and  1mVisibilityFul-0m
            1mlyObscured  22mis substituted.  For 1mProperty 22mevents, substituted with
            either the string 1mNewValue 22m(indicating that the property has  been
            created  or  modified) or 1mDelete 22m(indicating that the property has
            been removed).

       1m%t   22mThe 4mtime24m field from the event.  This is  the  X  server  timestamp
            (typically  the time since the last server reset) in milliseconds,
            when the event occurred.  Valid for most events.

       1m%w   22mThe 4mwidth24m field from the event.  Indicates the  new  or  requested
            width  of the window.  Valid only for 1mConfigure22m, 1mConfigureRequest22m,
            1mCreate22m, 1mResizeRequest22m, and 1mExpose 22mevents.

       1m%x22m, 1m%y0m
            The 4mx24m and 4my24m fields from the  event.   For  1mButtonPress22m,  1mButtonRe-0m
            1mlease22m, 1mMotion22m, 1mKeyPress22m, 1mKeyRelease22m, and 1mMouseWheel 22mevents, 1m%x 22mand
            1m%y 22mindicate the position of the  mouse  pointer  relative  to  the
            receiving  window.  For 1mEnter 22mand 1mLeave 22mevents, the position where
            the mouse pointer crossed the window, relative  to  the  receiving
            window.   For  1mConfigure  22mand 1mCreate 22mrequests, the 4mx24m and 4my24m coordi-
            nates of the window relative to its parent window.

       1m%A   22mSubstitutes the UNICODE character corresponding to the  event,  or
            the  empty  string  if  the  event doesn't correspond to a UNICODE
            character (e.g. the shift key was  pressed).  1mXmbLookupString  22m(or
            1mXLookupString  22mwhen  input  method support is turned off) does all
            the work of translating from the event  to  a  UNICODE  character.
            Valid only for 1mKeyPress 22mand 1mKeyRelease 22mevents.

       1m%B   22mThe  4mborder_width24m field from the event.  Valid only for 1mConfigure22m,
            1mConfigureRequest22m, and 1mCreate 22mevents.

       1m%D   22mThis reports the 4mdelta24m value of a  1mMouseWheel  22mevent.   The  4mdelta0m
            value  represents  the  rotation  units  the  mouse wheel has been
            moved.  On Windows 95 & 98 systems  the  smallest  value  for  the
            delta is 120.  Future systems may support higher resolution values
            for the delta.  The sign of the value represents the direction the
            mouse wheel was scrolled.

       1m%E   22mThe  4msend_event24m  field from the event.  Valid for all event types.
            1m0 22mindicates that this is a ``normal'' event, 1m1 22mindicates  that  it
            is a ``synthetic'' event generated by 1mSendEvent22m.

       1m%K   22mThe  keysym  corresponding  to the event, substituted as a textual
            string.  Valid only for 1mKeyPress 22mand 1mKeyRelease 22mevents.

       1m%N   22mThe keysym corresponding to the event, substituted  as  a  decimal
            number.  Valid only for 1mKeyPress 22mand 1mKeyRelease 22mevents.

       1m%P   22mThe  name  of  the property being updated or deleted (which may be
            converted to an XAtom using 1mwinfo atom22m.) Valid only  for  1mProperty0m
            events.

       1m%R   22mThe  4mroot24m window identifier from the event.  Valid only for events
            containing a 4mroot24m field.

       1m%S   22mThe 4msubwindow24m window identifier from the  event,  formatted  as  a
            hexadecimal  number.  Valid only for events containing a 4msubwindow0m
            field.

       1m%T   22mThe 4mtype24m field from the event.  Valid for all event types.

       1m%W   22mThe path name of the window to which the event was  reported  (the
            4mwindow24m field from the event).  Valid for all event types.

       1m%X   22mThe 4mx_root24m field from the event.  If a virtual-root window manager
            is being used then the substituted value is the  corresponding  x-
            coordinate  in the virtual root.  Valid only for 1mButtonPress22m, 1mBut-0m
            1mtonRelease22m, 1mKeyPress22m, 1mKeyRelease22m, and 1mMotion 22mevents.  Same meaning
            as 1m%x22m, except relative to the (virtual) root window.

       1m%Y   22mThe 4my_root24m field from the event.  If a virtual-root window manager
            is being used then the substituted value is the  corresponding  y-
            coordinate  in the virtual root.  Valid only for 1mButtonPress22m, 1mBut-0m
            1mtonRelease22m, 1mKeyPress22m, 1mKeyRelease22m, and 1mMotion 22mevents.  Same meaning
            as 1m%y22m, except relative to the (virtual) root window.

       The replacement string for a %-replacement is formatted as a proper Tcl
       list element.  This means that it will be surrounded with braces if  it
       contains  spaces, or special characters such as 1m$ 22mand 1m{ 22mmay be preceded
       by backslashes.  This guarantees that the string will be passed through
       the Tcl parser when the binding script is evaluated.  Most replacements
       are numbers or well-defined strings such as 1mAbove22m;  for these  replace-
       ments  no  special  formatting is ever necessary.  The most common case
       where reformatting occurs is for the 1m%A 22msubstitution.  For example,  if
       4mscript24m is
              1minsert %A0m
       and  the  character  typed  is  an open square bracket, then the script
       actually executed will be
              1minsert \[0m
       This will cause the 1minsert 22mto receive the original  replacement  string
       (open  square  bracket)  as its first argument.  If the extra backslash
       hadn't been added, Tcl would not have been able  to  parse  the  script
       correctly.

1mMULTIPLE MATCHES0m
       It  is  possible for several bindings to match a given X event.  If the
       bindings are associated with different 4mtag24m's, then each of the bindings
       will  be executed, in order.  By default, a binding for the widget will
       be executed first, followed by a  class  binding,  a  binding  for  its
       toplevel,  and  an  1mall  22mbinding.   The 1mbindtags 22mcommand may be used to
       change this order for a particular window or  to  associate  additional
       binding tags with the window.

       The  1mcontinue 22mand 1mbreak 22mcommands may be used inside a binding script to
       control the processing of matching scripts.  If  1mcontinue  22mis  invoked,
       then the current binding script is terminated but Tk will continue pro-
       cessing binding scripts associated with other 4mtag24m's.  If the 1mbreak 22mcom-
       mand  is  invoked  within a binding script, then that script terminates
       and no other scripts will be invoked for the event.

       If more than one binding matches a particular event and they  have  the
       same  4mtag24m,  then  the most specific binding is chosen and its script is
       evaluated.  The following tests are applied,  in  order,  to  determine
       which of several matching sequences is more specific: (a) an event pat-
       tern that specifies a specific button or key is more specific than  one
       that  doesn't;  (b)  a  longer  sequence  (in terms of number of events
       matched) is more specific than a shorter sequence; (c) if the modifiers
       specified  in one pattern are a subset of the modifiers in another pat-
       tern, then the pattern with more modifiers is  more  specific.   (d)  a
       virtual  event whose physical pattern matches the sequence is less spe-
       cific than the same physical pattern that is not associated with a vir-
       tual  event.   (e)  given  a  sequence that matches two or more virtual
       events, one of the virtual events will be  chosen,  but  the  order  is
       undefined.

       If  the  matching  sequences  contain  more  than one event, then tests
       (c)-(e) are applied in order from the most recent event  to  the  least
       recent event in the sequences.  If these tests fail to determine a win-
       ner, then the most recently registered sequence is the winner.

       If there are two (or more) virtual events that are  both  triggered  by
       the  same  sequence,  and both of those virtual events are bound to the
       same window tag, then only one of the virtual events will be triggered,
       and it will be picked at random:
              event add <<Paste>> <Control-y>
              event add <<Paste>> <Button-2>
              event add <<Scroll>> <Button-2>
              1mbind 22mEntry <<Paste>> {puts Paste}
              1mbind 22mEntry <<Scroll>> {puts Scroll}
       If the user types Control-y, the 1m<<Paste>> 22mbinding will be invoked, but
       if the user presses button 2 then one of either the  1m<<Paste>>  22mor  the
       1m<<Scroll>> 22mbindings will be invoked, but exactly which one gets invoked
       is undefined.

       If an X event does not match any of the  existing  bindings,  then  the
       event is ignored.  An unbound event is not considered to be an error.

1mMULTI-EVENT SEQUENCES AND IGNORED EVENTS0m
       When  a  4msequence24m  specified  in  a 1mbind 22mcommand contains more than one
       event pattern, then its script is executed whenever the  recent  events
       (leading  up  to  and  including  the  current  event)  match the given
       sequence.  This means, for example, that if button 1 is clicked repeat-
       edly  the  sequence 1m<Double-ButtonPress-1> 22mwill match each button press
       but the first.  If extraneous events that would prevent a  match  occur
       in  the  middle  of  an  event  sequence then the extraneous events are
       ignored unless they are 1mKeyPress 22mor 1mButtonPress 22mevents.   For  example,
       1m<Double-ButtonPress-1>  22mwill  match  a sequence of presses of button 1,
       even though there will be 1mButtonRelease  22mevents  (and  possibly  1mMotion0m
       events)  between the 1mButtonPress 22mevents.  Furthermore, a 1mKeyPress 22mevent
       may be preceded by any number of other  1mKeyPress  22mevents  for  modifier
       keys  without  the  modifier keys preventing a match.  For example, the
       event sequence 1maB 22mwill match a press of the 1ma 22mkey, a release of  the  1ma0m
       key,  a press of the 1mShift 22mkey, and a press of the 1mb 22mkey:  the press of
       1mShift 22mis ignored because it is a modifier  key.   Finally,  if  several
       1mMotion 22mevents occur in a row, only the last one is used for purposes of
       matching binding sequences.

1mERRORS0m
       If an error occurs in executing the script for a binding then the 1mbger-0m
       1mror 22mmechanism is used to report the error.  The 1mbgerror 22mcommand will be
       executed at global level (outside the context of any Tcl procedure).

1mEXAMPLES0m
       Arrange for a string describing the motion of the mouse to  be  printed
       out when the mouse is double-clicked:
              1mbind 22m. <Double-1> {
                  puts "hi from (%x,%y)"
              }

       A little GUI that displays what the keysym name of the last key pressed
       is:
              set keysym "Press any key"
              pack [label .l -textvariable keysym -padx 2m -pady 1m]
              1mbind 22m. <Key> {
                  set keysym "You pressed %K"
              }


1mSEE ALSO0m
       bgerror(n), bindtags(n), event(n), focus(n), grab(n), keysyms(n)


1mKEYWORDS0m
