1mNAME0m
       event  - Miscellaneous event facilities: define virtual events and gen-
       erate events

1mSYNOPSIS0m
       1mevent 4m22moption24m ?4marg24m 4marg24m 4m...24m?


1mDESCRIPTION0m
       The 1mevent 22mcommand provides several facilities for dealing  with  window
       system events, such as defining virtual events and synthesizing events.
       The command has several different forms, determined by the first  argu-
       ment.  The following forms are currently supported:

       1mevent add <<4m22mvirtual24m1m>> 4m22msequence24m ?4msequence24m 4m...24m?
              Associates  the  virtual  event  4mvirtual24m with the physical event
              sequence(s) given by the 4msequence24m arguments, so that the virtual
              event  will  trigger  whenever  any one of the 4msequence24ms occurs.
              4mVirtual24m may be any string value and 4msequence24m may have any of the
              values  allowed  for  the 4msequence24m argument to the 1mbind 22mcommand.
              If 4mvirtual24m is already defined, the new physical event  sequences
              add to the existing sequences for the event.

       1mevent delete <<4m22mvirtual24m1m>> 22m?4msequence24m 4msequence24m 4m...24m?
              Deletes  each  of  the  4msequence24ms from those associated with the
              virtual event given by 4mvirtual24m.  4mVirtual24m may be any string value
              and 4msequence24m may have any of the values allowed for the 4msequence0m
              argument to the 1mbind 22mcommand.  Any 4msequence24ms not currently asso-
              ciated  with  4mvirtual24m  are  ignored.  If no 4msequence24m argument is
              provided, all physical event sequences are removed for  4mvirtual24m,
              so that the virtual event will not trigger anymore.

       1mevent generate 4m22mwindow24m 4mevent24m ?4moption24m 4mvalue24m 4moption24m 4mvalue24m 4m...24m?
              Generates  a  window  event  and arranges for it to be processed
              just as if it had come from the window system.  4mWindow24m gives the
              path  name  of the window for which the event will be generated;
              it may also be an identifier (such as returned by 1mwinfo  id22m)  as
              long  as  it  is for a window in the current application.  4mEvent0m
              provides a basic description of the event, such  as  1m<Shift-But-0m
              1mton-2>  22mor  1m<<Paste>>22m.   If  4mWindow24m is empty the whole screen is
              meant, and coordinates are relative to the  screen.   4mEvent24m  may
              have  any  of the forms allowed for the 4msequence24m argument of the
              1mbind 22mcommand except that it must consist of a single event  pat-
              tern, not a sequence.  4mOption-value24m pairs may be used to specify
              additional attributes of the event, such as the x  and  y  mouse
              position;   see  EVENT FIELDS below.  If the 1m-when 22moption is not
              specified, the event is processed immediately:  all of the  han-
              dlers for the event will complete before the 1mevent generate 22mcom-
              mand returns.  If the 1m-when 22moption is specified then  it  deter-
              mines  when the event is processed.  Certain events, such as key
              events, require that the window has focus to receive  the  event
              properly.

       1mevent info 22m?<<4mvirtual24m1m>>22m?
              Returns  information  about  virtual events.  If the 1m<<4m22mvirtual24m1m>>0m
              argument is omitted, the return value is a list of all the  vir-
              tual events that are currently defined.  If 1m<<4m22mvirtual24m1m>> 22mis spec-
              ified then the return value is a list  whose  elements  are  the
              physical event sequences currently defined for the given virtual
              event;  if the virtual event is not defined then an empty string
              is returned.


1mEVENT FIELDS0m
       The  following  options  are  supported for the 1mevent generate 22mcommand.
       These correspond to the ``%'' expansions allowed in binding scripts for
       the 1mbind 22mcommand.

       1m-above 4m22mwindow0m
              4mWindow24m specifies the 4mabove24m field for the event, either as a win-
              dow path name or as an integer window id.  Valid  for  1mConfigure0m
              events.  Corresponds to the 1m%a 22msubstitution for binding scripts.

       1m-borderwidth 4m22msize0m
              4mSize24m must be a screen distance;  it specifies  the  4mborder_width0m
              field  for  the event.  Valid for 1mConfigure 22mevents.  Corresponds
              to the 1m%B 22msubstitution for binding scripts.

       1m-button 4m22mnumber0m
              4mNumber24m must be an integer;  it specifies the 4mdetail24m field for  a
              1mButtonPress  22mor 1mButtonRelease 22mevent, overriding any button  num-
              ber provided in the base 4mevent24m argument.  Corresponds to the  1m%b0m
              substitution for binding scripts.

       1m-count 4m22mnumber0m
              4mNumber24m must be an integer;  it specifies the 4mcount24m field for the
              event.  Valid for 1mExpose 22mevents.  Corresponds to the 1m%c  22msubsti-
              tution for binding scripts.

       1m-delta 4m22mnumber0m
              4mNumber24m must be an integer;  it specifies the 4mdelta24m field for the
              1mMouseWheel 22mevent.  The 4mdelta24m refers to the direction and  magni-
              tude  the  mouse  wheel  was  rotated.   Note the value is not a
              screen distance but are units of  motion  in  the  mouse  wheel.
              Typically  these  values are multiples of 120.  For example, 120
              should scroll the text widget up 4 lines and -240  would  scroll
              the  text  widget  down  8  lines.  Of course, other widgets may
              define different behaviors for mouse wheel motion.   This  field
              corresponds to the 1m%D 22msubstitution for binding scripts.

       1m-detail 4m22mdetail0m
              4mDetail24m  specifies the 4mdetail24m field for the event and must be one
              of the following:

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

              Valid for 1mEnter22m, 1mLeave22m, 1mFocusIn  22mand  1mFocusOut  22mevents.   Corre-
              sponds to the 1m%d 22msubstitution for binding scripts.

       1m-focus 4m22mboolean0m
              4mBoolean24m  must  be a boolean value;  it specifies the 4mfocus24m field
              for the event.  Valid for 1mEnter 22mand 1mLeave  22mevents.   Corresponds
              to the 1m%f 22msubstitution for binding scripts.

       1m-height 4m22msize0m
              4mSize24m  must  be a screen distance;  it specifies the 4mheight24m field
              for the event.  Valid for 1mConfigure 22mevents.  Corresponds to  the
              1m%h 22msubstitution for binding scripts.

       1m-keycode 4m22mnumber0m
              4mNumber24m   must be an integer;  it specifies the 4mkeycode24m field for
              the event.  Valid for 1mKeyPress 22mand  1mKeyRelease  22mevents.   Corre-
              sponds to the 1m%k 22msubstitution for binding scripts.

       1m-keysym 4m22mname0m
              4mName24m  must  be  the name of a valid keysym, such as 1mg22m, 1mspace22m, or
              1mReturn22m;  its corresponding keycode value is used as the  4mkeycode0m
              field  for  event,  overriding  any detail specified in the base
              4mevent24m argument.  Valid for 1mKeyPress 22mand 1mKeyRelease 22mevents.  Cor-
              responds to the 1m%K 22msubstitution for binding scripts.

       1m-mode 4m22mnotify0m
              4mNotify24m specifies the 4mmode24m field for the event and must be one of
              1mNotifyNormal22m, 1mNotifyGrab22m, 1mNotifyUngrab22m,  or  1mNotifyWhileGrabbed22m.
              Valid  for  1mEnter22m,  1mLeave22m, 1mFocusIn22m, and 1mFocusOut 22mevents.  Corre-
              sponds to the 1m%m 22msubstitution for binding scripts.

       1m-override 4m22mboolean0m
              4mBoolean24m must  be  a  boolean  value;   it  specifies  the  4mover-0m
              4mride_redirect24m field for the event.  Valid for 1mMap22m, 1mReparent22m, and
              1mConfigure 22mevents.  Corresponds to the 1m%o 22msubstitution for  bind-
              ing scripts.

       1m-place 4m22mwhere0m
              4mWhere24m  specifies  the  4mplace24m  field  for  the event;  it must be
              either 1mPlaceOnTop 22mor 1mPlaceOnBottom22m.  Valid for 1mCirculate 22mevents.
              Corresponds to the 1m%p 22msubstitution for binding scripts.

       1m-root 4m22mwindow0m
              4mWindow24m  must  be  either a window path name or an integer window
              identifier;  it specifies the 4mroot24m field for the  event.   Valid
              for  1mKeyPress22m,  1mKeyRelease22m,  1mButtonPress22m,  1mButtonRelease22m, 1mEnter22m,
              1mLeave22m, and 1mMotion 22mevents.  Corresponds to  the  1m%R  22msubstitution
              for binding scripts.

       1m-rootx 4m22mcoord0m
              4mCoord24m  must be a screen distance;  it specifies the 4mx_root24m field
              for the event.  Valid  for  1mKeyPress22m,  1mKeyRelease22m,  1mButtonPress22m,
              1mButtonRelease22m,  1mEnter22m, 1mLeave22m, and 1mMotion 22mevents.  Corresponds to
              the 1m%X 22msubstitution for binding scripts.

       1m-rooty 4m22mcoord0m
              4mCoord24m must be a screen distance;  it specifies th  4my_root24m  field
              for  the  event.   Valid  for 1mKeyPress22m, 1mKeyRelease22m, 1mButtonPress22m,
              1mButtonRelease22m, 1mEnter22m, 1mLeave22m, and 1mMotion 22mevents.  Corresponds  to
              the 1m%Y 22msubstitution for binding scripts.

       1m-sendevent 4m22mboolean0m
              1mBoolean  22mmust  be  a boolean value;  it specifies the 4msend_event0m
              field for the event.  Valid for all events.  Corresponds to  the
              1m%E 22msubstitution for binding scripts.

       1m-serial 4m22mnumber0m
              4mNumber24m  must  be  an integer;  it specifies the 4mserial24m field for
              the event.  Valid for all events.  Corresponds to the 1m%# 22msubsti-
              tution for binding scripts.

       1m-state 4m22mstate0m
              4mState24m  specifies  the  4mstate24m field for the event.  For 1mKeyPress22m,
              1mKeyRelease22m, 1mButtonPress22m, 1mButtonRelease22m, 1mEnter22m, 1mLeave22m, and 1mMotion0m
              events  it  must  be an integer value.  For 1mVisibility 22mevents it
              must  be  one  of  1mVisibilityUnobscured22m,  1mVisibilityPartiallyOb-0m
              1mscured22m,  or  1mVisibilityFullyObscured22m.  This option overrides any
              modifiers such as 1mMeta 22mor 1mControl 22mspecified in the  base  4mevent24m.
              Corresponds to the 1m%s 22msubstitution for binding scripts.

       1m-subwindow 4m22mwindow0m
              4mWindow24m  specifies the 4msubwindow24m field for the event, either as a
              path name for a Tk widget or as an  integer  window  identifier.
              Valid  for  1mKeyPress22m,  1mKeyRelease22m,  1mButtonPress22m,  1mButtonRelease22m,
              1mEnter22m, 1mLeave22m, and 1mMotion 22mevents.  Similar to 1m%S 22msubstitution for
              binding scripts.

       1m-time 4m22minteger0m
              4mInteger24m  must  be an integer value;  it specifies the 4mtime24m field
              for the event.  Valid  for  1mKeyPress22m,  1mKeyRelease22m,  1mButtonPress22m,
              1mButtonRelease22m,  1mEnter22m, 1mLeave22m, 1mMotion22m, and 1mProperty 22mevents.  Cor-
              responds to the 1m%t 22msubstitution for binding scripts.

       1m-warp 4m22mboolean0m
              4mboolean24m must be a  boolean  value;   it  specifies  whether  the
              screen  pointer  should  be warped as well.  Valid for 1mKeyPress22m,
              1mKeyRelease22m, 1mButtonPress22m, 1mButtonRelease22m, and 1mMotion 22mevents.   The
              pointer will only warp to a window if it is mapped.

       1m-width 4m22msize0m
              4mSize24m  must  be  a screen distance;  it specifies the 4mwidth24m field
              for the event.  Valid for 1mConfigure 22mevents.  Corresponds to  the
              1m%w 22msubstitution for binding scripts.

       1m-when 4m22mwhen0m
              4mWhen24m  determines when the event will be processed;  it must have
              one of the following values:

              1mnow       22mProcess the  event  immediately,  before  the  command
                        returns.   This  also  happens  if the 1m-when 22moption is
                        omitted.

              1mtail      22mPlace the event on Tcl's event queue behind any events
                        already queued for this application.

              1mhead      22mPlace  the event at the front of Tcl's event queue, so
                        that it  will  be  handled  before  any  other  events
                        already queued.

              1mmark      22mPlace  the event at the front of Tcl's event queue but
                        behind any other  events  already  queued  with  1m-when0m
                        1mmark22m.   This option is useful when generating a series
                        of events that should be processed in order but at the
                        front of the queue.

       1m-x 4m22mcoord0m
              4mCoord24m  must  be a screen distance;  it specifies the 4mx24m field for
              the event.  Valid for 1mKeyPress22m, 1mKeyRelease22m, 1mButtonPress22m, 1mButton-0m
              1mRelease22m,  1mMotion22m,  1mEnter22m, 1mLeave22m, 1mExpose22m, 1mConfigure22m, 1mGravity22m, and
              1mReparent 22mevents.  Corresponds to the  the  1m%x  22msubstitution  for
              binding  scripts.  If 4mWindow24m is empty the coordinate is relative
              to the screen, and this option corresponds to the  1m%X  22msubstitu-
              tion for binding scripts.

       1m-y 4m22mcoord0m
              4mCoord24m  must  be a screen distance;  it specifies the 4my24m field for
              the event.  Valid for 1mKeyPress22m, 1mKeyRelease22m, 1mButtonPress22m, 1mButton-0m
              1mRelease22m,  1mMotion22m,  1mEnter22m, 1mLeave22m, 1mExpose22m, 1mConfigure22m, 1mGravity22m, and
              1mReparent 22mevents.  Corresponds to the  the  1m%y  22msubstitution  for
              binding  scripts.  If 4mWindow24m is empty the coordinate is relative
              to the screen, and this option corresponds to the  1m%Y  22msubstitu-
              tion for binding scripts.

       Any  options that are not specified when generating an event are filled
       with the value 0, except for 4mserial24m, which is filled with  the  next  X
       event serial number.


1mVIRTUAL EVENT EXAMPLES0m
       In  order  for a virtual event binding to trigger, two things must hap-
       pen.  First, the virtual event must be defined with the 1mevent add  22mcom-
       mand.  Second, a binding must be created for the virtual event with the
       1mbind 22mcommand.  Consider the following virtual event definitions:
              event add <<Paste>> <Control-y>
              event add <<Paste>> <Button-2>
              event add <<Save>> <Control-X><Control-S>
              event add <<Save>> <Shift-F12>
       In the 1mbind 22mcommand, a virtual  event  can  be  bound  like  any  other
       builtin event type as follows:
              bind Entry <<Paste>> {%W insert [selection get]}
       The  double  angle brackets are used to specify that a virtual event is
       being bound.  If the user types Control-y or presses button 2, or if  a
       1m<<Paste>>  22mvirtual  event  is synthesized with 1mevent generate22m, then the
       1m<<Paste>> 22mbinding will be invoked.

       If a virtual binding has the exact same sequence as a separate physical
       binding,  then the physical binding will take precedence.  Consider the
       following example:
              event add <<Paste>> <Control-y> <Meta-Control-y>
              bind Entry <Control-y> {puts Control-y}
              bind Entry <<Paste>> {puts Paste}
       When the user types Control-y the 1m<Control-y> 22mbinding will be  invoked,
       because  a  physical  event  is considered more specific than a virtual
       event, all other things being equal.   However,  when  the  user  types
       Meta-Control-y  the 1m<<Paste>> 22mbinding will be invoked, because the 1mMeta0m
       modifier in the physical pattern associated with the virtual binding is
       more specific than the 1m<Control-y22m> sequence for the physical event.

       Bindings  on  a  virtual  event may be created before the virtual event
       exists.  Indeed, the virtual event never actually needs to be  defined,
       for instance, on platforms where the specific virtual event would mean-
       ingless or ungeneratable.

       When a definition of a virtual event changes at run time,  all  windows
       will respond immediately to the new definition.  Starting from the pre-
       ceding example, if the following code is executed:
              bind <Entry> <Control-y> {}
              event add <<Paste>> <Key-F6>
       the behavior will  change  such  in  two  ways.   First,  the  shadowed
       1m<<Paste>>  22mbinding will emerge.  Typing Control-y will no longer invoke
       the  1m<Control-y>  22mbinding,  but  instead  invoke  the   virtual   event
       1m<<Paste>>22m.   Second,  pressing  the  F6  key  will  now also invoke the
       1m<<Paste>> 22mbinding.


1mSEE ALSO0m
       bind


1mKEYWORDS0m
