NAME
event - Miscellaneous event facilities: define virtual events and gen-
erate events
SYNOPSIS
eevveenntt option ?arg arg ...?DESCRIPTION
The eevveenntt command provides several facilities for dealing with windowsystem 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: eevveenntt aadddd <<<>>> sequence ?sequence ...? Associates the virtual event virtual with the physical event
sequence(s) given by the sequence arguments, so that the virtualevent will trigger whenever any one of the sequences occurs.
Virtual may be any string value and sequence may have any of the values allowed for the sequence argument to the bbiinndd command.If virtual is already defined, the new physical event sequences
add to the existing sequences for the event.
eevveenntt ddeelleettee <<<>>> ?sequence sequence ...? Deletes each of the sequences from those associated with the virtual event given by virtual. Virtual may be any string value
and sequence may have any of the values allowed for the sequenceargument to the bbiinndd command. Any sequences not currently asso-
ciated with virtual are ignored. If no sequence argument isprovided, all physical event sequences are removed for virtual,
so that the virtual event will not trigger anymore.
eevveenntt ggeenneerraattee window event ?option value option value ...?
Generates a window event and arranges for it to be processed
just as if it had come from the window system. Window gives thepath name of the window for which the event will be generated; |
it may also be an identifier (such as returned by wwiinnffoo iidd) as | long as it is for a window in the current application. Eventprovides a basic description of the event, such as <
ttoonn-22>> or <<<
meant, and coordinates are relative to the screen. Event may have any of the forms allowed for the sequence argument of the>>>. If Window is empty the whole screen is bbiinndd command except that it must consist of a single event pat-
tern, not a sequence. Option-value 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 -wwhheenn option is not
specified, the event is processed immediately: all of the han-
dlers for the event will complete before the eevveenntt ggeenneerraattee com-
mand returns. If the -wwhheenn option 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. eevveenntt iinnffoo ?<>>>? Returns information about virtual events. If the <<<
>>> argument is omitted, the return value is a list of all the vir-
tual events that are currently defined. If <<<
ified then the return value is a list whose elements are the>>> is spec- physical event sequences currently defined for the given virtual
event; if the virtual event is not defined then an empty string
is returned. EEVVEENNTT FFIIEELLDDSS The following options are supported for the eevveenntt ggeenneerraattee command.These correspond to the ``%'' expansions allowed in binding scripts for
the bbiinndd command.-aabboovvee window
Window specifies the above field for the event, either as a win-
dow path name or as an integer window id. Valid for CCoonnffiigguurreeevents. Corresponds to the %%aa substitution for binding scripts.
-bboorrddeerrwwiiddtthh size
Size must be a screen distance; it specifies the borderwidthfield for the event. Valid for CCoonnffiigguurree events. Corresponds
to the %%BB substitution for binding scripts.
-bbuuttttoonn number
Number must be an integer; it specifies the detail field for aBBuuttttoonnPPrreessss or BBuuttttoonnRReelleeaassee event, overriding any button num-
ber provided in the base event argument. Corresponds to the %%bb
substitution for binding scripts.-ccoouunntt number
Number must be an integer; it specifies the count field for theevent. Valid for EExxppoossee events. Corresponds to the %%cc substi-
tution for binding scripts.-ddeellttaa number
Number must be an integer; it specifies the delta field for theMMoouusseeWWhheeeell event. The delta 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, 120should 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 fieldcorresponds to the %%DD substitution for binding scripts.
-ddeettaaiill detail
Detail specifies the detail field for the event and must be one
of the following: NNoottiiffyyAAnncceessttoorr NNoottiiffyyNNoonnlliinneeaarrVViirrttuuaall NNoottiiffyyDDeettaaiillNNoonnee NNoottiiffyyPPooiinntteerr NNoottiiffyyIInnffeerriioorr NNoottiiffyyPPooiinntteerrRRoooott NNoottiiffyyNNoonnlliinneeaarr NNoottiiffyyVViirrttuuaallValid for EEnntteerr, LLeeaavvee, FFooccuussIInn and FFooccuussOOuutt events. Corre-
sponds to the %%dd substitution for binding scripts.
-ffooccuuss boolean
Boolean must be a boolean value; it specifies the focus fieldfor the event. Valid for EEnntteerr and LLeeaavvee events. Corresponds
to the %%ff substitution for binding scripts.
-hheeiigghhtt size
Size must be a screen distance; it specifies the height fieldfor the event. Valid for CCoonnffiigguurree events. Corresponds to the
%%hh substitution for binding scripts.
-kkeeyyccooddee number
Number must be an integer; it specifies the keycode field forthe event. Valid for KKeeyyPPrreessss and KKeeyyRReelleeaassee events. Corre-
sponds to the %%kk substitution for binding scripts.
-kkeeyyssyymm name
Name must be the name of a valid keysym, such as gg, ssppaaccee, or RReettuurrnn; its corresponding keycode value is used as the keycodefield for event, overriding any detail specified in the base
event argument. Valid for KKeeyyPPrreessss and KKeeyyRReelleeaassee events. Cor-
responds to the %%KK substitution for binding scripts.
-mmooddee notify
Notify specifies the mode field for the event and must be one of
NNoottiiffyyNNoorrmmaall, NNoottiiffyyGGrraabb, NNoottiiffyyUUnnggrraabb, or NNoottiiffyyWWhhiilleeGGrraabbbbeedd.Valid for EEnntteerr, LLeeaavvee, FFooccuussIInn, and FFooccuussOOuutt events. Corre-
sponds to the %%mm substitution for binding scripts.
-oovveerrrriiddee boolean
Boolean must be a boolean value; it specifies the overridere-
direct field for the event. Valid for MMaapp, RReeppaarreenntt, and CCoonn-
ffiigguurree events. Corresponds to the %%oo substitution for binding
scripts.-ppllaaccee where
Where specifies the place field for the event; it must be
either PPllaacceeOOnnTToopp or PPllaacceeOOnnBBoottttoomm. Valid for CCiirrccuullaattee events.
Corresponds to the %%pp substitution for binding scripts.
-rroooott window
Window must be either a window path name or an integer windowidentifier; it specifies the root field for the event. Valid
for KKeeyyPPrreessss, KKeeyyRReelleeaassee, BBuuttttoonnPPrreessss, BBuuttttoonnRReelleeaassee, EEnntteerr,LLeeaavvee, and MMoottiioonn events. Corresponds to the %%RR substitution
for binding scripts.-rroooottxx coord
Coord must be a screen distance; it specifies the xroot fieldfor the event. Valid for KKeeyyPPrreessss, KKeeyyRReelleeaassee, BBuuttttoonnPPrreessss,
BBuuttttoonnRReelleeaassee, EEnntteerr, LLeeaavvee, and MMoottiioonn events. Corresponds to
the %%XX substitution for binding scripts.
-rroooottyy coord
Coord must be a screen distance; it specifies th yroot fieldfor the event. Valid for KKeeyyPPrreessss, KKeeyyRReelleeaassee, BBuuttttoonnPPrreessss,
BBuuttttoonnRReelleeaassee, EEnntteerr, LLeeaavvee, and MMoottiioonn events. Corresponds to
the %%YY substitution for binding scripts.
-sseennddeevveenntt boolean
BBoooolleeaann must be a boolean value; it specifies the sendevent
field for the event. Valid for all events. Corresponds to the
%%EE substitution for binding scripts.
-sseerriiaall number
Number must be an integer; it specifies the serial field forthe event. Valid for all events. Corresponds to the %%## substi-
tution for binding scripts.-ssttaattee state
State specifies the state field for the event. For KKeeyyPPrreessss,
KKeeyyRReelleeaassee, BBuuttttoonnPPrreessss, BBuuttttoonnRReelleeaassee, EEnntteerr, LLeeaavvee, and MMoottiioonnevents it must be an integer value. For VViissiibbiilliittyy events it
must be one of VViissiibbiilliittyyUUnnoobbssccuurreedd, VViissiibbiilliittyyPPaarrttiiaallllyyOObb-
ssccuurreedd, or VViissiibbiilliittyyFFuullllyyOObbssccuurreedd. This option overrides anymodifiers such as MMeettaa or CCoonnttrrooll specified in the base event.
Corresponds to the %%ss substitution for binding scripts.
-ssuubbwwiinnddooww window
Window specifies the subwindow field for the event, either as a
path name for a Tk widget or as an integer window identifier. Valid for KKeeyyPPrreessss, KKeeyyRReelleeaassee, BBuuttttoonnPPrreessss, BBuuttttoonnRReelleeaassee,EEnntteerr, LLeeaavvee, and MMoottiioonn events. Similar to %%SS substitution for
binding scripts.-ttiimmee integer
Integer must be an integer value; it specifies the time fieldfor the event. Valid for KKeeyyPPrreessss, KKeeyyRReelleeaassee, BBuuttttoonnPPrreessss,
BBuuttttoonnRReelleeaassee, EEnntteerr, LLeeaavvee, MMoottiioonn, and PPrrooppeerrttyy events. Cor-
responds to the %%tt substitution for binding scripts.
-wwaarrpp boolean
boolean must be a boolean value; it specifies whether the screen pointer should be warped as well. Valid for KKeeyyPPrreessss,KKeeyyRReelleeaassee, BBuuttttoonnPPrreessss, BBuuttttoonnRReelleeaassee, and MMoottiioonn events. The
pointer will only warp to a window if it is mapped.-wwiiddtthh size
Size must be a screen distance; it specifies the width fieldfor the event. Valid for CCoonnffiigguurree events. Corresponds to the
%%ww substitution for binding scripts.
-wwhheenn when
When determines when the event will be processed; it must have
one of the following values:nnooww Process the event immediately, before the command
returns. This also happens if the -wwhheenn option is
omitted.ttaaiill Place the event on Tcl's event queue behind any events
already queued for this application.hheeaadd Place the event at the front of Tcl's event queue, so
that it will be handled before any other events
already queued.mmaarrkk Place the event at the front of Tcl's event queue but
behind any other events already queued with -wwhheenn
mmaarrkk. This option is useful when generating a seriesof events that should be processed in order but at the
front of the queue.-xx coord
Coord must be a screen distance; it specifies the x field forthe event. Valid for KKeeyyPPrreessss, KKeeyyRReelleeaassee, BBuuttttoonnPPrreessss, BBuuttttoonn-
RReelleeaassee, MMoottiioonn, EEnntteerr, LLeeaavvee, EExxppoossee, CCoonnffiigguurree, GGrraavviittyy, andRReeppaarreenntt events. Corresponds to the the %%xx substitution for
binding scripts. If Window is empty the coordinate is relativeto the screen, and this option corresponds to the %%XX substitu-
tion for binding scripts.-yy coord
Coord must be a screen distance; it specifies the y field forthe event. Valid for KKeeyyPPrreessss, KKeeyyRReelleeaassee, BBuuttttoonnPPrreessss, BBuuttttoonn-
RReelleeaassee, MMoottiioonn, EEnntteerr, LLeeaavvee, EExxppoossee, CCoonnffiigguurree, GGrraavviittyy, andRReeppaarreenntt events. Corresponds to the the %%yy substitution for
binding scripts. If Window is empty the coordinate is relativeto the screen, and this option corresponds to the %%YY substitu-
tion for binding scripts.Any options that are not specified when generating an event are filled
with the value 0, except for serial, which is filled with the next Xevent serial number.
VVIIRRTTUUAALL EEVVEENNTT EEXXAAMMPPLLEESSIn order for a virtual event binding to trigger, two things must hap-
pen. First, the virtual event must be defined with the eevveenntt aadddd com-
mand. Second, a binding must be created for the virtual event with the
bbiinndd command. Consider the following virtual event definitions:
event add <
> event add <
> event add <
> event add <
> In the bbiinndd command, a virtual event can be bound like any other
builtin event type as follows:
bind Entry <
> {%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
<<<
<<<>>> virtual event is synthesized with eevveenntt ggeenneerraattee, then the >>> binding 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 <
> bind Entry
bind Entry <{puts Control-y} > {puts Paste} When the user types Control-y the <
> binding 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 <<<
modifier in the physical pattern associated with the virtual binding is>>> binding will be invoked, because the MMeettaa more specific than the <
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
{} event add <
the behavior will change such in two ways. First, the shadowed> <<<
>>> binding will emerge. Typing Control-y will no longer invoke the <
<<<> binding, but instead invoke the virtual event >>>. Second, pressing the F6 key will now also invoke the <<< >>> binding. SEE ALSO
bind KKEEYYWWOORRDDSSevent, binding, define, handle, virtual event
Tk 8.3 event(n)