diff options
Diffstat (limited to 'doc/bind.n')
-rw-r--r-- | doc/bind.n | 394 |
1 files changed, 205 insertions, 189 deletions
@@ -15,7 +15,6 @@ bind \- Arrange for X events to invoke Tcl scripts .SH SYNOPSIS \fBbind\fI tag\fR ?\fIsequence\fR? ?\fB+\fR??\fIscript\fR? .BE - .SH "INTRODUCTION" .PP The \fBbind\fR command associates Tcl scripts with X events. @@ -23,7 +22,9 @@ If all three arguments are specified, \fBbind\fR will arrange for \fIscript\fR (a Tcl script) to be evaluated whenever the event(s) given by \fIsequence\fR occur in the window(s) identified by \fItag\fR. -If \fIscript\fR is prefixed with a ``+'', then it is appended to +If \fIscript\fR is prefixed with a +.QW + , +then it is appended to any existing binding for \fIsequence\fR; otherwise \fIscript\fR replaces any existing binding. If \fIscript\fR is an empty string then the current binding for @@ -64,17 +65,15 @@ the binding applies to all windows in the application. .PP The \fIsequence\fR argument specifies a sequence of one or more event patterns, with optional white space between the patterns. Each -.VS event pattern may take one of three forms. In the simplest case it is a single -.VE printing ASCII character, such as \fBa\fR or \fB[\fR. The character may not be a space character or the character \fB<\fR. This form of pattern matches a \fBKeyPress\fR event for the particular character. The second form of pattern is longer but more general. It has the following syntax: .CS -\fB<\fImodifier-modifier-type-detail\fB>\fR +\fB<\fImodifier\-modifier\-type\-detail\fB>\fR .CE The entire event pattern is surrounded by angle brackets. Inside the angle brackets are zero or more modifiers, an event @@ -82,7 +81,6 @@ type, and an extra piece of information (\fIdetail\fR) identifying a particular button or keysym. Any of the fields may be omitted, as long as at least one of \fItype\fR and \fIdetail\fR is present. The fields must be separated by white space or dashes. -.VS .PP The third form of pattern is used to specify a user-defined, named virtual event. It has the following syntax: @@ -95,26 +93,26 @@ Modifiers, such as \fBShift\fR or \fBControl\fR, 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. +respond immediately to the new definition. .PP Some widgets (e.g. \fBmenu\fR and \fBtext\fR) issue virtual events when their internal state is updated in some ways. Please see the manual page for each widget for details. -.VE -.SH "MODIFIERS" +.SS "MODIFIERS" .PP Modifiers consist of any of the following values: .DS .ta 6c -\fBControl\fR \fBMod2, M2\fR -\fBShift\fR \fBMod3, M3\fR -\fBLock\fR \fBMod4, M4\fR -\fBButton1, B1\fR \fBMod5, M5\fR -\fBButton2, B2\fR \fBMeta, M\fR -\fBButton3, B3\fR \fBAlt\fR -\fBButton4, B4\fR \fBDouble\fR -\fBButton5, B5\fR \fBTriple\fR -\fBMod1, M1\fR \fBQuadruple\fR +\fBControl\fR \fBMod1\fR, \fBM1\fR, \fBCommand\fR +\fBAlt\fR \fBMod2\fR, \fBM2\fR, \fBOption\fR +\fBShift\fR \fBMod3\fR, \fBM3\fR +\fBLock\fR \fBMod4\fR, \fBM4\fR +\fBExtended\fR \fBMod5\fR, \fBM5\fR +\fBButton1\fR, \fBB1\fR \fBMeta\fR, \fBM\fR +\fBButton2\fR, \fBB2\fR \fBDouble\fR +\fBButton3\fR, \fBB3\fR \fBTriple\fR +\fBButton4\fR, \fBB4\fR \fBQuadruple\fR +\fBButton5\fR, \fBB5\fR .DE Where more than one value is listed, separated by commas, the values are equivalent. @@ -126,8 +124,8 @@ must include all of those specified in the event pattern. An event may also contain additional modifiers not specified in the binding. For example, if button 1 is pressed while the shift and control keys -are down, the pattern \fB<Control-Button-1>\fR will match -the event, but \fB<Mod1-Button-1>\fR will not. +are down, the pattern \fB<Control\-Button\-1>\fR will match +the event, but \fB<Mod1\-Button\-1>\fR will not. If no modifiers are specified, then any combination of modifiers may be present in the event. .PP @@ -146,11 +144,24 @@ events. They cause a particular 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 \fBDouble\fR, \fBTriple\fR or \fBQuadruple\fR pattern, all of the events must occur close together in time and without -substantial mouse motion in between. For example, \fB<Double-Button-1>\fR -is equivalent to \fB<Button-1><Button-1>\fR with the extra time and space +substantial mouse motion in between. For example, \fB<Double\-Button\-1>\fR +is equivalent to \fB<Button\-1><Button\-1>\fR with the extra time and space requirement. - -.SH "EVENT TYPES" +.PP +The \fBCommand\fR and \fBOption\fR modifiers are equivalents of \fBMod1\fR +resp. \fBMod2\fR, they correspond to Macintosh-specific modifier keys. +.PP +.VS 8.5 +The \fBExtended\fR modifier is, at present, specific to Windows. It +appears on events that are associated with the keys on the +.QW "extended keyboard" . +On a US keyboard, the extended keys include the \fBAlt\fR +and \fBControl\fR keys at the right of the keyboard, the cursor keys +in the cluster to the left of the numeric pad, the \fBNumLock\fR key, +the \fBBreak\fR key, the \fBPrintScreen\fR key, and the \fB/\fR and +\fBEnter\fR keys in the numeric keypad. +.VE 8.5 +.SS "EVENT TYPES" .PP The \fItype\fR field may be any of the standard X event types, with a few extra abbreviations. The \fItype\fR field will also accept a @@ -158,19 +169,18 @@ 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. .DS -.ta \w'ButtonPress, Button\0\0\0'u +\w'KeyPress, Key\0\0\0'u -\fBActivate Destroy Map -ButtonPress, Button Enter MapRequest -ButtonRelease Expose Motion -Circulate FocusIn MouseWheel -CirculateRequest FocusOut Property -Colormap Gravity Reparent -Configure KeyPress, Key ResizeRequest -ConfigureRequest KeyRelease Unmap -Create Leave Visibility -Deactivate\fR +.ta \w'\fBButtonPress, Button\0\0\0\fR'u +\w'\fBKeyPress, Key\0\0\0\fR'u +\fBActivate\fR \fBDestroy\fR \fBMap\fR +\fBButtonPress\fR, \fBButton\fR \fBEnter\fR \fBMapRequest\fR +\fBButtonRelease\fR \fBExpose\fR \fBMotion\fR +\fBCirculate\fR \fBFocusIn\fR \fBMouseWheel\fR +\fBCirculateRequest\fR \fBFocusOut\fR \fBProperty\fR +\fBColormap\fR \fBGravity\fR \fBReparent\fR +\fBConfigure\fR \fBKeyPress\fR, \fBKey\fR \fBResizeRequest\fR +\fBConfigureRequest\fR \fBKeyRelease\fR \fBUnmap\fR +\fBCreate\fR \fBLeave\fR \fBVisibility\fR +\fBDeactivate\fR .DE -.VS 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 @@ -189,165 +199,163 @@ active. Likewise, the \fBDeactive\fR event is sent when the window's state changes from active to deactive. There are no useful percent substitutions you would make when binding to these events. .IP \fBMouseWheel\fR 5 -Some mice on the Windows platform support a mouse wheel which is used +Many contemporary mice support a mouse wheel, which is used for scrolling documents without using the scrollbars. By rolling the wheel, the system will generate \fBMouseWheel\fR events that the -application can use to scroll. On Windows, the event is -always routed to the window that currently has focus (like \fBKey\fR -events.) On Mac OS X, -the event is routed to the window under the pointer. When the event +application can use to scroll. Like \fBKey\fR events the event is +always routed to the window that currently has focus. When the event is received you can use the \fB%D\fR substitution to get the \fIdelta\fR 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. -Positive values should scroll up and negative values should scroll down. -.VE -.IP "\fBKeyPress\fP, \fBKeyRelease\fP" 5 -The \fBKeyPress\fP and \fBKeyRelease\fP events are generated -whenever a key is pressed or released. \fBKeyPress\fP and \fBKeyRelease\fP +resolution devices may be available in the future. The sign of the +value determines which direction your widget should scroll. Positive +values should scroll up and negative values should scroll down. +.IP "\fBKeyPress\fR, \fBKeyRelease\fR" 5 +The \fBKeyPress\fR and \fBKeyRelease\fR events are generated +whenever a key is pressed or released. \fBKeyPress\fR and \fBKeyRelease\fR events are sent to the window which currently has the keyboard focus. -.IP "\fBButtonPress\fP, \fBButtonRelease\fP, \fBMotion\fP" 5 -The \fBButtonPress\fP and \fBButtonRelease\fP events +.IP "\fBButtonPress\fR, \fBButtonRelease\fR, \fBMotion\fR" 5 +The \fBButtonPress\fR and \fBButtonRelease\fR events are generated when the user presses or releases a mouse button. -\fBMotion\fP events are generated whenever the pointer is moved. -\fBButtonPress\fP, \fBButtonRelease\fP, and \fBMotion\fP events are +\fBMotion\fR events are generated whenever the pointer is moved. +\fBButtonPress\fR, \fBButtonRelease\fR, and \fBMotion\fR events are normally sent to the window containing the pointer. .RS .PP When a mouse button is pressed, the window containing the pointer automatically obtains a temporary pointer grab. -Subsequent \fBButtonPress\fP, \fBButtonRelease\fP, and \fBMotion\fP +Subsequent \fBButtonPress\fR, \fBButtonRelease\fR, and \fBMotion\fR events will be sent to that window, regardless of which window contains the pointer, until all buttons have been released. .RE -.IP \fBConfigure\fP 5 -A \fBConfigure\fP event is sent to a window whenever its +.IP \fBConfigure\fR 5 +A \fBConfigure\fR event is sent to a window whenever its size, position, or border width changes, and sometimes when it has changed position in the stacking order. -.IP "\fBMap\fP, \fBUnmap\fP" 5 -The \fBMap\fP and \fBUnmap\fP events are generated whenever the mapping +.IP "\fBMap\fR, \fBUnmap\fR" 5 +The \fBMap\fR and \fBUnmap\fR events are generated whenever the mapping state of a window changes. .RS .PP Windows are created in the unmapped state. Top-level windows become mapped when they transition to the -\fBnormal\fP state, and are unmapped in the \fBwithdrawn\fP -and \fBiconic\fP states. +\fBnormal\fR state, and are unmapped in the \fBwithdrawn\fR +and \fBiconic\fR states. Other windows become mapped when they are placed under control -of a geometry manager (for example \fBpack\fP or \fBgrid\fP). +of a geometry manager (for example \fBpack\fR or \fBgrid\fR). .PP -A window is \fIviewable\fP only if it and all of its ancestors are mapped. -Note that geometry managers typically do not map their children until +A window is \fIviewable\fR 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 \fBMap\fP and \fBUnmap\fP +when they become unmapped; hence in Tk \fBMap\fR and \fBUnmap\fR events indicate whether or not a window is viewable. .RE -.IP \fBVisibility\fP 5 -A window is said to be \fIobscured\fP when another window +.IP \fBVisibility\fR 5 +A window is said to be \fIobscured\fR when another window above it in the stacking order fully or partially overlaps it. -\fBVisibility\fP events are generated whenever a window's -obscurity state changes; the \fIstate\fP field (\fB%s\fP) +\fBVisibility\fR events are generated whenever a window's +obscurity state changes; the \fIstate\fR field (\fB%s\fR) specifies the new state. -.IP \fBExpose\fP 5 -An \fBExpose\fP event is generated whenever all or part of a +.IP \fBExpose\fR 5 +An \fBExpose\fR event 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 \fBExpose\fP events, since Tk handles them internally. -.IP \fBDestroy\fP 5 -A \fBDestroy\fP event is delivered to a window when +It is normally not necessary for client applications to +handle \fBExpose\fR events, since Tk handles them internally. +.IP \fBDestroy\fR 5 +A \fBDestroy\fR event is delivered to a window when it is destroyed. .RS .PP -When the \fBDestroy\fP event is delivered -to a widget, it is in a ``half-dead'' state: the widget still exists, -but most operations on it will fail. +When the \fBDestroy\fR event is delivered +to a widget, it is in a +.QW half-dead +state: the widget still exists, but most operations on it will fail. .RE -.IP "\fBFocusIn\fP, \fBFocusOut\fP" 5 -The \fBFocusIn\fP and \fBFocusOut\fP events are generated +.IP "\fBFocusIn\fR, \fBFocusOut\fR" 5 +The \fBFocusIn\fR and \fBFocusOut\fR events are generated whenever the keyboard focus changes. -A \fBFocusOut\fP event is sent to the old focus window, -and a \fBFocusIn\fP event is sent to the new one. +A \fBFocusOut\fR event is sent to the old focus window, +and a \fBFocusIn\fR event is sent to the new one. .RS .PP In addition, if the old and new focus windows do not share a common parent, -``virtual crossing'' focus events are sent to the intermediate -windows in the hierarchy. -Thus a \fBFocusIn\fP event indicates +.QW "virtual crossing" +focus events are sent to the intermediate windows in the hierarchy. +Thus a \fBFocusIn\fR event indicates that the target window or one of its descendants has acquired the focus, -and a \fBFocusOut\fP event indicates that the focus +and a \fBFocusOut\fR event indicates that the focus has been changed to a window outside the target window's hierarchy. .PP -The keyboard focus may be changed explicitly by a call to \fBfocus\fP, -or implicitly by the window manager. +The keyboard focus may be changed explicitly by a call to \fBfocus\fR, +or implicitly by the window manager. .RE -.IP "\fBEnter\fP, \fBLeave\fP" 5 -An \fBEnter\fP event is sent to a window when the pointer -enters that window, and a \fBLeave\fP event is sent when -the pointer leaves it. +.IP "\fBEnter\fR, \fBLeave\fR" 5 +An \fBEnter\fR event is sent to a window when the pointer +enters that window, and a \fBLeave\fR event is sent when +the pointer leaves it. .RS .PP -If there is a pointer grab in effect, \fBEnter\fP and \fBLeave\fP +If there is a pointer grab in effect, \fBEnter\fR and \fBLeave\fR events are only delivered to the window owning the grab. .PP In addition, when the pointer moves -between two windows, \fBEnter\fP and \fBLeave\fP -``virtual crossing'' events are sent to intermediate windows -in the hierarchy in the same manner as for \fBFocusIn\fP and -\fBFocusOut\fP events. +between two windows, \fBEnter\fR and \fBLeave\fR +.QW "virtual crossing" +events are sent to intermediate windows +in the hierarchy in the same manner as for \fBFocusIn\fR and +\fBFocusOut\fR events. .RE -.IP \fBProperty\fP -A \fBProperty\fP event is sent to a window whenever an X property +.IP \fBProperty\fR +A \fBProperty\fR event is sent to a window whenever an X property belonging to that window is changed or deleted. -\fBProperty\fP events are not normally delivered to Tk applications as +\fBProperty\fR events are not normally delivered to Tk applications as they are handled by the Tk core. -.IP \fBColormap\fP -A \fBColormap\fP event is generated whenever the colormap +.IP \fBColormap\fR +A \fBColormap\fR event is generated whenever the colormap associated with a window has been changed, installed, or uninstalled. .RS .PP Widgets may be assigned a private colormap by -specifying a \fB-colormap\fP option; the window manager +specifying a \fB\-colormap\fR option; the window manager is responsible for installing and uninstalling colormaps as necessary. .PP Note that Tk provides no useful details for this event type. .RE '\" The following events were added in TIP#47 -.IP "\fBMapRequest\fP, \fBCirculateRequest\fP, \fBResizeRequest\fP, \fBConfigureRequest\fP, \fBCreate\fP" 5 +.IP "\fBMapRequest\fR, \fBCirculateRequest\fR, \fBResizeRequest\fR, \fBConfigureRequest\fR, \fBCreate\fR" 5 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 \fBSubstructureRedirectMask\fP on a window; +selected \fBSubstructureRedirectMask\fR on a window; the Tk core does not use this mask.) -.IP "\fBGravity\fP, \fBReparent\fP, \fBCirculate\fP" 5 -The events \fBGravity\fP and \fBReparent\fP +.IP "\fBGravity\fR, \fBReparent\fR, \fBCirculate\fR" 5 +The events \fBGravity\fR and \fBReparent\fR are not normally delivered to Tk applications. They are included for completeness. .RS .PP -A \fBCirculate\fP event indicates that the window has moved +A \fBCirculate\fR event indicates that the window has moved to the top or to the bottom of the stacking order as -a result of an \fBXCirculateSubwindows\fP protocol request. +a result of an \fBXCirculateSubwindows\fR protocol request. Note that the stacking order may be changed for other reasons -which do not generate a \fBCirculate\fP event, and that -Tk does not use \fBXCirculateSubwindows()\fP internally. +which do not generate a \fBCirculate\fR event, and that +Tk does not use \fBXCirculateSubwindows()\fR internally. This event type is included only for completeness; there is no reliable way to track changes to a window's position in the stacking order. .RE -.SH "EVENT DETAILS" +.SS "EVENT DETAILS" .PP The last part of a long event specification is \fIdetail\fR. In the case of a \fBButtonPress\fR or \fBButtonRelease\fR event, it is the -number of a button (1-5). If a button number is given, then only an +number of a button (1\-5). If a button number is given, then only an event on that particular button will match; if no button number is given, then an event on any button will match. Note: giving a specific button number is different than specifying a button modifier; @@ -356,17 +364,22 @@ 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 \fItype\fR may be omitted: if will default to \fBButtonPress\fR. For example, the specifier \fB<1>\fR -is equivalent to \fB<ButtonPress-1>\fR. +is equivalent to \fB<ButtonPress\-1>\fR. .PP If the event type is \fBKeyPress\fR or \fBKeyRelease\fR, then \fIdetail\fR may be specified 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 +they include all the alphanumeric ASCII characters (e.g. +.QW a +is the keysym for the ASCII character +.QW a ), +plus descriptions for non-alphanumeric characters +.PQ comma "is the keysym for the comma character" , +plus descriptions for all the non-ASCII keys on the keyboard (e.g. +.QW Shift_L +is the keysym for the left shift key, and +.QW 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. @@ -374,8 +387,8 @@ If necessary, you can use the \fB%K\fR notation described below to print out the keysym name for a particular key. If a keysym \fIdetail\fR is given, then the \fItype\fR field may be omitted; it will default to \fBKeyPress\fR. -For example, \fB<Control-comma>\fR is equivalent to -\fB<Control-KeyPress-comma>\fR. +For example, \fB<Control\-comma>\fR is equivalent to +\fB<Control\-KeyPress\-comma>\fR. .SH "BINDING SCRIPTS AND SUBSTITUTIONS" .PP The \fIscript\fR argument to \fBbind\fR is a Tcl script, @@ -406,49 +419,58 @@ The \fIabove\fR field from the event, formatted as a hexadecimal number. Valid only for \fBConfigure\fR events. Indicates the sibling window immediately below the receiving window -in the stacking order, or \fB0\fP if the receiving window is at the +in the stacking order, or \fB0\fR if the receiving window is at the bottom. .IP \fB%b\fR 5 The number of the button that was pressed or released. Valid only for \fBButtonPress\fR and \fBButtonRelease\fR events. .IP \fB%c\fR 5 The \fIcount\fR field from the event. Valid only for \fBExpose\fR events. -Indicates that there are \fIcount\fP pending \fBExpose\fP events which have not +Indicates that there are \fIcount\fR pending \fBExpose\fR events which have not yet been delivered to the window. .IP \fB%d\fR 5 -The \fIdetail\fR field from the event. The \fB%d\fR is replaced by +The \fIdetail\fR +.VS 8.5 +or \fIuser_data\fR +.VE 8.5 +field from the event. The \fB%d\fR is replaced by a string identifying the detail. For \fBEnter\fR, \fBLeave\fR, \fBFocusIn\fR, and \fBFocusOut\fR events, the string will be one of the following: .RS .DS .ta 6c -\fBNotifyAncestor NotifyNonlinearVirtual -NotifyDetailNone NotifyPointer -NotifyInferior NotifyPointerRoot -NotifyNonlinear NotifyVirtual\fR +\fBNotifyAncestor\fR \fBNotifyNonlinearVirtual\fR +\fBNotifyDetailNone\fR \fBNotifyPointer\fR +\fBNotifyInferior\fR \fBNotifyPointerRoot\fR +\fBNotifyNonlinear\fR \fBNotifyVirtual\fR .DE For \fBConfigureRequest\fR events, the string will be one of: .DS .ta 6c -\fBAbove Opposite -Below None -BottomIf TopIf\fR +\fBAbove\fR \fBOpposite\fR +\fBBelow\fR \fBNone\fR +\fBBottomIf\fR \fBTopIf\fR .DE +.VS 8.5 +For virtual events, the string will be whatever value is stored in the +\fIuser_data\fR field when the event was created (typically with +\fBevent generate\fR), or the empty string if the field is NULL. +Virtual events corresponding to key sequence presses (see \fBevent +add\fR for details) set the \fIuser_data\fR to NULL. +.VE 8.5 For events other than these, the substituted string is undefined. .RE .IP \fB%f\fR 5 The \fIfocus\fR field from the event (\fB0\fR or \fB1\fR). Valid only -for \fBEnter\fR and \fBLeave\fR events. \fB1\fP if the receiving -window is the focus window or a descendant of the focus window, -\fB0\fP otherwise. +for \fBEnter\fR and \fBLeave\fR events. \fB1\fR if the receiving +window is the focus window or a descendant of the focus window, +\fB0\fR otherwise. .IP \fB%h\fR 5 -.VS The \fIheight\fR field from the event. Valid for the \fBConfigure\fR, \fBConfigureRequest\fR, \fBCreate\fR, \fBResizeRequest\fR, and \fBExpose\fR events. Indicates the new or requested height of the window. -.VE .IP \fB%i\fR 5 The \fIwindow\fR field from the event, represented as a hexadecimal integer. Valid for all event types. @@ -458,10 +480,8 @@ and \fBKeyRelease\fR events. .IP \fB%m\fR 5 The \fImode\fR field from the event. The substituted string is one of \fBNotifyNormal\fR, \fBNotifyGrab\fR, \fBNotifyUngrab\fR, or -.VS \fBNotifyWhileGrabbed\fR. Valid only for \fBEnter\fR, \fBFocusIn\fR, \fBFocusOut\fR, and \fBLeave\fR events. -.VE .IP \fB%o\fR 5 The \fIoverride_redirect\fR field from the event. Valid only for \fBMap\fR, \fBReparent\fR, and \fBConfigure\fR events. @@ -476,36 +496,34 @@ The \fIstate\fR field from the event. For \fBButtonPress\fR, is substituted. For \fBVisibility\fR, one of the strings \fBVisibilityUnobscured\fR, \fBVisibilityPartiallyObscured\fR, and \fBVisibilityFullyObscured\fR is substituted. -For \fBProperty\fP events, substituted with -either the string \fBNewValue\fP (indicating that the property -has been created or modified) or \fBDelete\fP (indicating that +For \fBProperty\fR events, substituted with +either the string \fBNewValue\fR (indicating that the property +has been created or modified) or \fBDelete\fR (indicating that the property has been removed). .IP \fB%t\fR 5 The \fItime\fR 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. +Valid for most events. .IP \fB%w\fR 5 The \fIwidth\fR field from the event. Indicates the new or requested width of the window. Valid only for -.VS \fBConfigure\fR, \fBConfigureRequest\fR, \fBCreate\fR, \fBResizeRequest\fR, and \fBExpose\fR events. -.VE .IP "\fB%x\fR, \fB%y\fR" 5 The \fIx\fR and \fIy\fR fields from the event. -For \fBButtonPress\fP, \fBButtonRelease\fP, \fBMotion\fP, -\fBKeyPress\fP, \fBKeyRelease\fP, and \fBMouseWheel\fP events, -\fB%x\fP and \fB%y\fP indicate the position of the mouse pointer +For \fBButtonPress\fR, \fBButtonRelease\fR, \fBMotion\fR, +\fBKeyPress\fR, \fBKeyRelease\fR, and \fBMouseWheel\fR events, +\fB%x\fR and \fB%y\fR indicate the position of the mouse pointer relative to the receiving window. -For \fBEnter\fP and \fBLeave\fP events, the position where the +For \fBEnter\fR and \fBLeave\fR events, the position where the mouse pointer crossed the window, relative to the receiving window. -For \fBConfigure\fP and \fBCreate\fP requests, the \fIx\fP and \fIy\fP +For \fBConfigure\fR and \fBCreate\fR requests, the \fIx\fR and \fIy\fR coordinates of the window relative to its parent window. .IP \fB%A\fR 5 Substitutes the UNICODE character corresponding to the event, or -the empty string if the event doesn't correspond to a UNICODE character +the empty string if the event does not correspond to a UNICODE character (e.g. the shift key was pressed). \fBXmbLookupString\fR (or \fBXLookupString\fR when input method support is turned off) does all the work of translating from the event to a UNICODE character. @@ -514,18 +532,19 @@ Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. The \fIborder_width\fR field from the event. Valid only for \fBConfigure\fR, \fBConfigureRequest\fR, and \fBCreate\fR events. .IP \fB%D\fR 5 -.VS This reports the \fIdelta\fR value of a \fBMouseWheel\fR event. The \fIdelta\fR 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. -.VE .IP \fB%E\fR 5 The \fIsend_event\fR field from the event. Valid for all event types. -\fB0\fP indicates that this is a ``normal'' event, \fB1\fP indicates -that it is a ``synthetic'' event generated by \fBSendEvent\fP. +\fB0\fR indicates that this is a +.QW normal +event, \fB1\fR indicates that it is a +.QW synthetic +event generated by \fBSendEvent\fR. .IP \fB%K\fR 5 The keysym corresponding to the event, substituted as a textual string. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. @@ -535,7 +554,7 @@ number. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. .IP \fB%P\fR 5 The name of the property being updated or deleted (which may be converted to an XAtom using \fBwinfo atom\fR.) Valid -only for \fBProperty\fP events. +only for \fBProperty\fR events. .IP \fB%R\fR 5 The \fIroot\fR window identifier from the event. Valid only for events containing a \fIroot\fR field. @@ -548,27 +567,19 @@ The \fItype\fR field from the event. Valid for all event types. .IP \fB%W\fR 5 The path name of the window to which the event was reported (the \fIwindow\fR field from the event). Valid for all event types. -.IP \fB%X\fR 5 -The \fIx_root\fR field from the event. +.IP "\fB%X\fR, \fB%Y\fR" 5 +The \fIx_root\fR and \fIy_root\fR fields 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. +values are the corresponding x-coordinate and y-coordinate in the virtual root. Valid only for \fBButtonPress\fR, \fBButtonRelease\fR, \fBKeyPress\fR, \fBKeyRelease\fR, and \fBMotion\fR events. -Same meaning as \fB%x\fP, except relative to the (virtual) root window. -.IP \fB%Y\fR 5 -The \fIy_root\fR 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 -\fBButtonPress\fR, \fBButtonRelease\fR, \fBKeyPress\fR, \fBKeyRelease\fR, -and \fBMotion\fR events. -Same meaning as \fB%y\fP, except relative to the (virtual) root window. +Same meaning as \fB%x\fR and \fB%y\fR, except relative to the (virtual) root +window. .LP 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 \fB$\fR and +This means that spaces or special characters such as \fB$\fR and \fB{\fR may be preceded by backslashes. This guarantees that the string will be passed through the Tcl parser when the binding script is evaluated. @@ -587,7 +598,7 @@ actually executed will be .CE This will cause the \fBinsert\fR to 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 +If the extra backslash had not been added, Tcl would not have been able to parse the script correctly. .SH "MULTIPLE MATCHES" .PP @@ -615,36 +626,43 @@ have the same \fItag\fR, 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 pattern that specifies a specific button or key is more specific -than one that doesn't; -(b) a longer sequence (in terms of number +.RS +.IP (a) +an event pattern that specifies a specific button or key is more specific +than one that does not; +.IP (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 +.IP (c) +if the modifiers specified in one pattern are a subset of the modifiers in another pattern, then the pattern with more modifiers is more specific. -(d) a virtual event whose physical pattern matches the sequence is less -specific than the same physical pattern that is not associated with a +.IP (d) +a virtual event whose physical pattern matches the sequence is less +specific than the same physical pattern that is not associated with a virtual event. -(e) given a sequence that matches two or more virtual events, one +.IP (e) +given a sequence that matches two or more virtual events, one of the virtual events will be chosen, but the order is undefined. +.RE .PP 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 +(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 winner, then the most recently registered sequence is the winner. .PP 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: +be picked at random: .CS -event add <<Paste>> <Control-y> -event add <<Paste>> <Button-2> -event add <<Scroll>> <Button-2> +event add <<Paste>> <Control\-y> +event add <<Paste>> <Button\-2> +event add <<Scroll>> <Button\-2> \fBbind\fR Entry <<Paste>> {puts Paste} \fBbind\fR Entry <<Scroll>> {puts Scroll} .CE -If the user types Control-y, the \fB<<Paste>>\fR binding +If the user types Control\-y, the \fB<<Paste>>\fR binding will be invoked, but if the user presses button 2 then one of either the \fB<<Paste>>\fR or the \fB<<Scroll>>\fR bindings will be invoked, but exactly which one gets invoked is undefined. @@ -658,12 +676,12 @@ When a \fIsequence\fR specified in a \fBbind\fR command 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 repeatedly the sequence \fB<Double-ButtonPress-1>\fR will match +clicked repeatedly the sequence \fB<Double\-ButtonPress\-1>\fR will 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 \fBKeyPress\fR or \fBButtonPress\fR events. -For example, \fB<Double-ButtonPress-1>\fR will match a sequence of +For example, \fB<Double\-ButtonPress\-1>\fR will match a sequence of presses of button 1, even though there will be \fBButtonRelease\fR events (and possibly \fBMotion\fR events) between the \fBButtonPress\fR events. @@ -686,7 +704,7 @@ The \fBbgerror\fR command will be executed at global level Arrange for a string describing the motion of the mouse to be printed out when the mouse is double-clicked: .CS -\fBbind\fR . <Double-1> { +\fBbind\fR . <Double\-1> { puts "hi from (%x,%y)" } .CE @@ -695,14 +713,12 @@ A little GUI that displays what the keysym name of the last key pressed is: .CS set keysym "Press any key" -pack [label .l -textvariable keysym -padx 2m -pady 1m] +pack [label .l \-textvariable keysym \-padx 2m \-pady 1m] \fBbind\fR . <Key> { set keysym "You pressed %K" } .CE - .SH "SEE ALSO" bgerror(n), bindtags(n), event(n), focus(n), grab(n), keysyms(n) - .SH KEYWORDS binding, event |