📄 bind.n
字号:
'\"'\" Copyright (c) 1990 The Regents of the University of California.'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" SCCS: @(#) bind.n 1.41 96/10/03 18:27:05'\" .so man.macros.TH bind n 4.1 Tk "Tk Built-In Commands".BS'\" Note: do not modify the .SH NAME line immediately below!.SH NAMEbind \- Arrange for X events to invoke Tcl scripts.SH SYNOPSIS\fBbind\fI tag\fR.sp\fBbind\fI tag sequence\fR.sp\fBbind\fI tag sequence script\fR.sp\fBbind\fI tag sequence \fB+\fIscript\fR.BE.SH INTRODUCTION.PPThe \fBbind\fR command associates Tcl scripts with X events.If all three arguments are specified, \fBbind\fR willarrange for \fIscript\fR (a Tcl script) to be evaluated wheneverthe 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 toany existing binding for \fIsequence\fR; otherwise \fIscript\fR replacesany existing binding.If \fIscript\fR is an empty string then the current binding for\fIsequence\fR is destroyed, leaving \fIsequence\fR unbound.In all of the cases where a \fIscript\fR argument is provided,\fBbind\fR returns an empty string..PPIf \fIsequence\fR is specified without a \fIscript\fR, then thescript currently bound to \fIsequence\fR is returned, oran empty string is returned if there is no binding for \fIsequence\fR.If neither \fIsequence\fR nor \fIscript\fR is specified, then thereturn value is a list whose elements are all the sequencesfor which there exist bindings for \fItag\fR..PPThe \fItag\fR argument determines which window(s) the binding applies to.If \fItag\fR begins with a dot, as in \fB.a.b.c\fR, then it mustbe the path name for a window; otherwise it may be an arbitrarystring.Each window has an associated list of tags, and a binding appliesto a particular window if its tag is among those specified forthe window.Although the \fBbindtags\fR command may be used to assign anarbitrary set of binding tags to a window, the default bindingtags provide the following behavior:.IPIf a tag is the name of an internal window the binding appliesto that window..IPIf the tag is the name of a toplevel window the binding appliesto the toplevel window and all its internal windows..IPIf the tag is the name of a class of widgets, such as \fBButton\fR,the binding applies to all widgets in that class;.IPIf \fItag\fR has the value \fBall\fR,the binding applies to all windows in the application..SH "EVENT PATTERNS".PPThe \fIsequence\fR argument specifies a sequence of one or moreevent patterns, with optional white space between the patterns. Each.VSevent pattern maytake one of three forms. In the simplest case it is a single.VEprinting ASCII character, such as \fBa\fR or \fB[\fR. The charactermay not be a space character or the character \fB<\fR. This form ofpattern matches a \fBKeyPress\fR event for the particularcharacter. The second form of pattern is longer but more general.It has the following syntax:.CS\fB<\fImodifier-modifier-type-detail\fB>\fR.CEThe entire event pattern is surrounded by angle brackets.Inside the angle brackets are zero or more modifiers, an eventtype, and an extra piece of information (\fIdetail\fR) identifyinga 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.PPThe third form of pattern is used to specify a user-defined, named virtualevent. It has the following syntax:.CS\fB<<\fIname\fB>>\fR.CEThe entire virtual event pattern is surrounded by double angle brackets.Inside the angle brackets is the user-defined name of the virtual event.Modifiers, such as \fBShift\fR or \fBControl\fR, may not be combined with avirtual event to modify it. Bindings on a virtual event may be createdbefore the virtual event is defined, and if the definition of a virtualevent changes dynamically, all windows bound to that virtual event willrespond immediately to the new definition. .VE.SH "MODIFIERS".PPModifiers 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.DEWhere more than one value is listed, separated by commas, the valuesare equivalent.Most of the modifiers have the obvious X meanings.For example, \fBButton1\fR requires thatbutton 1 be depressed when the event occurs.For a binding to match a given event, the modifiers in the eventmust include all of those specified in the event pattern.An event may also contain additional modifiers not specified inthe binding.For example, if button 1 is pressed while the shift and control keysare down, the pattern \fB<Control-Button-1>\fR will matchthe event, but \fB<Mod1-Button-1>\fR will not.If no modifiers are specified, then any combination of modifiers maybe present in the event..PP\fBMeta\fR and \fBM\fR refer to whichever of the\fBM1\fR through \fBM5\fR modifiers is associated with the metakey(s) on the keyboard (keysyms \fBMeta_R\fR and \fBMeta_L\fR).If there are no meta keys, or if they are not associated with anymodifiers, then \fBMeta\fR and \fBM\fR will not match any events.Similarly, the \fBAlt\fR modifier refers to whichever modifieris associated with the alt key(s) on the keyboard (keysyms\fBAlt_L\fR and \fBAlt_R\fR)..PPThe \fBDouble\fR and \fBTriple\fR modifiers are a conveniencefor specifying double mouse clicks and other repeatedevents. They cause a particular event pattern to berepeated 2 or 3 times, and also place a time and space requirementon the sequence: for a sequence of events to match a \fBDouble\fRor \fBTriple\fR pattern, all of the events must occur close togetherin time and without substantial mouse motion in between.For example, \fB<Double-Button-1>\fRis equivalent to \fB<Button-1><Button-1>\fR with the extratime and space requirement..SH "EVENT TYPES".PPThe \fItype\fR field may be any of the standard X event types, with afew extra abbreviations. Below is a list of all the valid types;where two names appear together, they are synonyms..DS C.ta 5c 10c\fBButtonPress, Button Expose MapButtonRelease FocusIn MotionCirculate FocusOut Property Colormap Gravity ReparentConfigure KeyPress, Key UnmapDestroy KeyRelease VisibilityEnter Leave ActivateDeactivate\fR.DE.PPThe last part of a long event specification is \fIdetail\fR. In thecase of a \fBButtonPress\fR or \fBButtonRelease\fR event, it is thenumber of a button (1-5). If a button number is given, then only anevent on that particular button will match; if no button number isgiven, then an event on any button will match. Note: giving aspecific button number is different 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 alreadydepressed when the matching event occurs. If a buttonnumber is given then \fItype\fR may be omitted: if will defaultto \fBButtonPress\fR. For example, the specifier \fB<1>\fRis equivalent to \fB<ButtonPress-1>\fR..PPIf the event type is \fBKeyPress\fR or \fBKeyRelease\fR, then\fIdetail\fR may be specified in the form of an X keysym. Keysymsare textual specifications for particular keys on the keyboard;they include all the alphanumeric ASCII characters (e.g. ``a'' isthe keysym for the ASCII character ``a''), plus descriptions fornon-alphanumeric characters (``comma'' is the keysym for the commacharacter), plus descriptions for all the non-ASCII keys on thekeyboard (``Shift_L'' is the keysm for the left shift key, and``F1'' is the keysym for the F1 function key, if it exists). Thecomplete list of keysyms is not presented here; it isavailable in other X documentation and may vary from system tosystem.If necessary, you can use the \fB%K\fR notation described belowto 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..SH "BINDING SCRIPTS AND SUBSTITUTIONS".PPThe \fIscript\fR argument to \fBbind\fR is a Tcl script,which will be executed whenever the given event sequence occurs.\fICommand\fR will be executed in the same interpreter that the\fBbind\fR command was executed in, and it will run at globallevel (only global variables will be accessible).If \fIscript\fR containsany \fB%\fR characters, then the script will not beexecuted directly. Instead, a new script will begenerated by replacing each \fB%\fR, and the character followingit, with information from the current event. The replacementdepends on the character following the \fB%\fR, as defined in thelist below. Unless otherwise indicated, thereplacement string is the decimal value of the given field fromthe current event.Some of the substitutions are only valid forcertain types of events; if they are used for other types of eventsthe value substituted is undefined..IP \fB%%\fR 5Replaced with a single percent..IP \fB%#\fR 5The number of the last client request processed by the server(the \fIserial\fR field from the event). Valid for all eventtypes..IP \fB%a\fR 5The \fIabove\fR field from the event,formatted as a hexadecimal number.Valid only for \fBConfigure\fR events..IP \fB%b\fR 5The number of the button that was pressed or released. Valid onlyfor \fBButtonPress\fR and \fBButtonRelease\fR events.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -