event.n
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:15k
- '"
- '" Copyright (c) 1996 Sun Microsystems, Inc.
- '" Copyright (c) 1998-2000 Ajuba Solutions.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: event.n,v 1.6.8.1 2004/10/28 10:19:29 dkf Exp $
- '"
- .so man.macros
- .TH event n 8.3 Tk "Tk Built-In Commands"
- .BS
- '" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- event - Miscellaneous event facilities: define virtual events and generate events
- .SH SYNOPSIS
- fBeventfI option fR?fIarg arg ...fR?
- .BE
- .SH DESCRIPTION
- .PP
- The fBeventfR command 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 argument. The following forms are currently supported:
- .TP
- fBevent add <<fIvirtualfB>>fI sequence fR?fIsequence ...fR?
- Associates the virtual event fIvirtualfR with the physical
- event sequence(s) given by the fIsequencefR arguments, so that
- the virtual event will trigger whenever any one of the fIsequencefRs
- occurs.
- fIVirtualfR may be any string value and fIsequencefR may have
- any of the values allowed for the fIsequencefR argument to the
- fBbindfR command.
- If fIvirtualfR is already defined, the new physical event sequences
- add to the existing sequences for the event.
- .TP
- fBevent delete <<fIvirtualfB>> fR?fIsequencefR fIsequence ...fR?
- Deletes each of the fIsequencefRs from those associated with
- the virtual event given by fIvirtualfR.
- fIVirtualfR may be any string value and fIsequencefR may have
- any of the values allowed for the fIsequencefR argument to the
- fBbindfR command.
- Any fIsequencefRs not currently associated with fIvirtualfR
- are ignored.
- If no fIsequencefR argument is provided, all physical event sequences
- are removed for fIvirtualfR, so that the virtual event will not
- trigger anymore.
- .TP
- fBevent generate fIwindow event fR?fIoption value option value ...fR?
- Generates a window event and arranges for it to be processed just as if
- it had come from the window system.
- fIWindowfR gives the path name of the window for which the event
- .VS 8.3
- will be generated; it may also be an identifier (such as returned by
- fBwinfo idfR) as long as it is for a window in the current application.
- .VE
- fIEventfR provides a basic description of
- the event, such as fB<Shift-Button-2>fR or fB<<Paste>>fR.
- If fIWindowfR is empty the whole screen is meant, and coordinates
- are relative to the screen.
- fIEventfR may have any of the forms allowed for the fIsequencefR
- argument of the fBbindfR command except that it must consist
- of a single event pattern, not a sequence.
- fIOption-valuefR 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 fB-whenfR option is not specified, the
- event is processed immediately: all of the handlers for the event
- will complete before the fBevent generatefR command returns.
- If the fB-whenfR option is specified then it determines when the
- event is processed. Certain events, such as key events, require
- that the window has focus to receive the event properly.
- .TP
- fBevent info fR?<<fIvirtualfB>>fR?
- Returns information about virtual events.
- If the fB<<fIvirtualfB>>fR argument is omitted, the return value
- is a list of all the virtual events that are currently defined.
- If fB<<fIvirtualfB>>fR is specified 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.
- .SH "EVENT FIELDS"
- .PP
- The following options are supported for the fBevent generatefR
- command. These correspond to the ``%'' expansions
- allowed in binding scripts for the fBbindfR command.
- .TP
- fB-abovefI windowfR
- fIWindowfR specifies the fIabovefR field for the event,
- either as a window path name or as an integer window id.
- Valid for fBConfigurefR events.
- Corresponds to the fB%afR substitution for binding scripts.
- .TP
- fB-borderwidthfI sizefR
- fISizefR must be a screen distance; it specifies the
- fIborder_widthfR field for the event.
- Valid for fBConfigurefR events.
- Corresponds to the fB%BfR substitution for binding scripts.
- .TP
- fB-buttonfI numberfR
- fINumberfR must be an integer; it specifies the fIdetailfR field
- for a fBButtonPressfR or fBButtonReleasefR event, overriding
- any button number provided in the base fIeventfR argument.
- Corresponds to the fB%bfR substitution for binding scripts.
- .TP
- fB-countfI numberfR
- fINumberfR must be an integer; it specifies the fIcountfR field
- for the event. Valid for fBExposefR events.
- Corresponds to the fB%cfR substitution for binding scripts.
- .TP
- fB-deltafI numberfR
- fINumberfR must be an integer; it specifies the fIdeltafR field
- for the fBMouseWheelfR event. The fIdeltafR refers to the
- direction and magnitude 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
- fB%DfR substitution for binding scripts.
- .TP
- fB-detailfI detailfR
- fIDetailfR specifies the fIdetailfR field for the event
- and must be one of the following:
- .RS
- .DS
- .ta 6c
- fBNotifyAncestor NotifyNonlinearVirtual
- NotifyDetailNone NotifyPointer
- NotifyInferior NotifyPointerRoot
- NotifyNonlinear NotifyVirtualfR
- .DE
- Valid for fBEnterfR, fBLeavefR, fBFocusInfR and
- fBFocusOutfR events.
- Corresponds to the fB%dfR substitution for binding scripts.
- .RE
- .TP
- fB-focusfI booleanfR
- fIBooleanfR must be a boolean value; it specifies the fIfocusfR
- field for the event.
- Valid for fBEnterfR and fBLeavefR events.
- Corresponds to the fB%ffR substitution for binding scripts.
- .TP
- fB-heightfI sizefR
- fISizefR must be a screen distance; it specifies the fIheightfR
- field for the event. Valid for fBConfigurefR events.
- Corresponds to the fB%hfR substitution for binding scripts.
- .TP
- fB-keycodefI numberfR
- fINumberfR must be an integer; it specifies the fIkeycodefR
- field for the event.
- Valid for fBKeyPressfR and fBKeyReleasefR events.
- Corresponds to the fB%kfR substitution for binding scripts.
- .TP
- fB-keysymfI namefR
- fINamefR must be the name of a valid keysym, such as fBgfR,
- fBspacefR, or fBReturnfR; its corresponding
- keycode value is used as the fIkeycodefR field for event, overriding
- any detail specified in the base fIeventfR argument.
- Valid for fBKeyPressfR and fBKeyReleasefR events.
- Corresponds to the fB%KfR substitution for binding scripts.
- .TP
- fB-modefI notifyfR
- fINotifyfR specifies the fImodefR field for the event and must be
- one of fBNotifyNormalfR, fBNotifyGrabfR, fBNotifyUngrabfR, or
- fBNotifyWhileGrabbedfR.
- Valid for fBEnterfR, fBLeavefR, fBFocusInfR, and
- fBFocusOutfR events.
- Corresponds to the fB%mfR substitution for binding scripts.
- .TP
- fB-overridefI booleanfR
- fIBooleanfR must be a boolean value; it specifies the
- fIoverride_redirectfR field for the event.
- Valid for fBMapfR, fBReparentfR, and fBConfigurefR events.
- Corresponds to the fB%ofR substitution for binding scripts.
- .TP
- fB-placefI wherefR
- fIWherefR specifies the fIplacefR field for the event; it must be
- either fBPlaceOnTopfR or fBPlaceOnBottomfR.
- Valid for fBCirculatefR events.
- Corresponds to the fB%pfR substitution for binding scripts.
- .TP
- fB-rootfI windowfR
- fIWindowfR must be either a window path name or an integer window
- identifier; it specifies the fIrootfR field for the event.
- Valid for fBKeyPressfR, fBKeyReleasefR, fBButtonPressfR,
- fBButtonReleasefR, fBEnterfR, fBLeavefR, and fBMotionfR
- events.
- Corresponds to the fB%RfR substitution for binding scripts.
- .TP
- fB-rootxfI coordfR
- fICoordfR must be a screen distance; it specifies the fIx_rootfR
- field for the event.
- Valid for fBKeyPressfR, fBKeyReleasefR, fBButtonPressfR,
- fBButtonReleasefR, fBEnterfR, fBLeavefR, and fBMotionfR
- events. Corresponds to the fB%XfR substitution for binding scripts.
- .TP
- fB-rootyfI coordfR
- fICoordfR must be a screen distance; it specifies the fIy_rootfR
- field for the event.
- Valid for fBKeyPressfR, fBKeyReleasefR, fBButtonPressfR,
- fBButtonReleasefR, fBEnterfR, fBLeavefR, and fBMotionfR
- events.
- Corresponds to the fB%YfR substitution for binding scripts.
- .TP
- fB-sendeventfI booleanfR
- fIBooleanfR must be a boolean value; it specifies the fIsend_eventfR
- field for the event. Valid for all events. Corresponds to the
- fB%EfR substitution for binding scripts.
- .TP
- fB-serialfI numberfR
- fINumberfR must be an integer; it specifies the fIserialfR field
- for the event. Valid for all events.
- Corresponds to the fB%#fR substitution for binding scripts.
- .TP
- fB-statefI statefR
- fIStatefR specifies the fIstatefR field for the event.
- For fBKeyPressfR, fBKeyReleasefR, fBButtonPressfR,
- fBButtonReleasefR, fBEnterfR, fBLeavefR, and fBMotionfR events
- it must be an integer value.
- For fBVisibilityfR events it must be one of fBVisibilityUnobscuredfR,
- fBVisibilityPartiallyObscuredfR, or fBVisibilityFullyObscuredfR.
- This option overrides any modifiers such as fBMetafR or fBControlfR
- specified in the base fIeventfR.
- Corresponds to the fB%sfR substitution for binding scripts.
- .TP
- fB-subwindowfI windowfR
- fIWindowfR specifies the fIsubwindowfR field for the event, either
- as a path name for a Tk widget or as an integer window identifier.
- Valid for fBKeyPressfR, fBKeyReleasefR, fBButtonPressfR,
- fBButtonReleasefR, fBEnterfR, fBLeavefR, and fBMotionfR events.
- Similar to fB%SfR substitution for binding scripts.
- .TP
- fB-timefI integerfR
- fIIntegerfR must be an integer value; it specifies the fItimefR field
- for the event.
- Valid for fBKeyPressfR, fBKeyReleasefR, fBButtonPressfR,
- fBButtonReleasefR, fBEnterfR, fBLeavefR, fBMotionfR,
- and fBPropertyfR events.
- Corresponds to the fB%tfR substitution for binding scripts.
- .TP
- fB-warpfI booleanfR
- fIbooleanfR must be a boolean value; it specifies whether
- the screen pointer should be warped as well.
- Valid for fBKeyPressfR, fBKeyReleasefR, fBButtonPressfR,
- fBButtonReleasefR, and fBMotionfR events. The pointer will
- only warp to a window if it is mapped.
- .TP
- fB-widthfI sizefR
- fISizefR must be a screen distance; it specifies the fIwidthfR field
- for the event.
- Valid for fBConfigurefR events.
- Corresponds to the fB%wfR substitution for binding scripts.
- .TP
- fB-whenfI whenfR
- fIWhenfR determines when the event will be processed; it must have one
- of the following values:
- .RS
- .IP fBnowfR 10
- Process the event immediately, before the command returns.
- This also happens if the fB-whenfR option is omitted.
- .IP fBtailfR 10
- Place the event on Tcl's event queue behind any events already
- queued for this application.
- .IP fBheadfR 10
- Place the event at the front of Tcl's event queue, so that it
- will be handled before any other events already queued.
- .IP fBmarkfR 10
- Place the event at the front of Tcl's event queue but behind any
- other events already queued with fB-when markfR.
- This option is useful when generating a series of events that should
- be processed in order but at the front of the queue.
- .RE
- .TP
- fB-xfI coordfR
- fICoordfR must be a screen distance; it specifies the fIxfR field
- for the event.
- Valid for fBKeyPressfR, fBKeyReleasefR, fBButtonPressfR,
- fBButtonReleasefR, fBMotionfR, fBEnterfR, fBLeavefR,
- fBExposefR, fBConfigurefR, fBGravityfR, and fBReparentfR
- events.
- Corresponds to the fB%xfR substitution for binding scripts.
- If fIWindowfR is empty the coordinate is relative to the
- screen, and this option corresponds to the fB%XfR substitution
- for binding scripts.
- .TP
- fB-yfI coordfR
- fICoordfR must be a screen distance; it specifies the fIyfR
- field for the event.
- Valid for fBKeyPressfR, fBKeyReleasefR, fBButtonPressfR,
- fBButtonReleasefR, fBMotionfR, fBEnterfR, fBLeavefR,
- fBExposefR, fBConfigurefR, fBGravityfR, and fBReparentfR
- events.
- Corresponds to the fB%yfR substitution for binding scripts.
- If fIWindowfR is empty the coordinate is relative to the
- screen, and this option corresponds to the fB%YfR substitution
- for binding scripts.
- .PP
- Any options that are not specified when generating an event are filled
- with the value 0, except for fIserialfR, which is filled with the
- next X event serial number.
- .SH "VIRTUAL EVENT EXAMPLES"
- .PP
- In order for a virtual event binding to trigger, two things must
- happen. First, the virtual event must be defined with the
- fBevent addfR command. Second, a binding must be created for
- the virtual event with the fBbindfR command.
- Consider the following virtual event definitions:
- .CS
- event add <<Paste>> <Control-y>
- event add <<Paste>> <Button-2>
- event add <<Save>> <Control-X><Control-S>
- event add <<Save>> <Shift-F12>
- .CE
- In the fBbindfR command, a virtual event can be bound like any other
- builtin event type as follows:
- .CS
- bind Entry <<Paste>> {%W insert [selection get]}
- .CE
- 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 fB<<Paste>>fR virtual event is synthesized with fBevent generatefR,
- then the fB<<Paste>>fR binding will be invoked.
- .PP
- 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:
- .CS
- event add <<Paste>> <Control-y> <Meta-Control-y>
- bind Entry <Control-y> {puts Control-y}
- bind Entry <<Paste>> {puts Paste}
- .CE
- When the user types Control-y the fB<Control-y>fR 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
- fB<<Paste>>fR binding will be invoked, because the
- fBMetafR modifier in the physical pattern associated with the
- virtual binding is more specific than the fB<Control-yfR> sequence for
- the physical event.
- .PP
- 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 meaningless or
- ungeneratable.
- .PP
- When a definition of a virtual event changes at run time, all windows
- will respond immediately to the new definition.
- Starting from the preceding example, if the following code is executed:
- .CS
- bind <Entry> <Control-y> {}
- event add <<Paste>> <Key-F6>
- .CE
- the behavior will change such in two ways. First, the shadowed
- fB<<Paste>>fR binding will emerge.
- Typing Control-y will no longer invoke the fB<Control-y>fR binding,
- but instead invoke the virtual event fB<<Paste>>fR. Second,
- pressing the F6 key will now also invoke the fB<<Paste>>fR binding.
- .SH "SEE ALSO"
- bind(n)
- .SH KEYWORDS
- event, binding, define, handle, virtual event