Charles.Forsyth20060303-partialeea662d19 years agoHistory
194 lines · 6.3 KB · Text
RawDownload
.TH BIND 9.SH NAMEbind \- Arrange for events to invoke Tk scripts.SH SYNOPSIS\f5bind\fI tag sequence script\fR.sp\f5bind\fI tag sequence \f5+\fIscript\fR.SH INTRODUCTIONThe \f5bind\fR command associates Tk scripts with window events.If all three arguments are specified, \f5bind\fR willarrange for \fIscript\fR (a Tk 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,\f5bind\fR returns an empty string.If \fIscript\fR is prefixed with a ``-'', then any existing binding for\fIsequence\fR, whose script is exactly the same as \fIscript\fR, is removed.The \fItag\fR argument gives the pathname of the windowto which \fIsequence\fR is bound..SH "EVENT PATTERNS"The \fIsequence\fR argument specifies a sequence of one or moreevent patterns, with optional white space between the patterns.  Eachevent pattern maytake one of two forms.  In the simplest case it is a singleprinting ASCII character, such as \f5a\fR or \f5[\fR.  The charactermay not be a space character or the character \f5<\fR.  This form ofpattern matches a \f5KeyPress\fR event for the particularcharacter.  The second form of pattern is longer but more general.It has the following syntax:.RS.EX\f5<\fIevent\f5-\fIevent\f5-\fR...\f5-\fIevent\f5>\fR.EE.REThe following events are accepted:.TP.BR Key \ or\  KeypressThis represents the press of the character in the following.IR event .If there is no following event, this represents the press ofany key. The key letter may be escaped with a backslash.RB ( \e )to prevent any character (e.g..BR > )from being treated specially..TP.B ConfigureThis event occurs whenever the widget is configuredsuch that its requested size changes..TP.B ControlThis represents the press of the character in the following.Ieventwith the Control key pressed. The character may be quotedas for.BR Key ..TP.BR ButtonPress \ or\  ButtonThis represents the pressed state of the mouse button given bythe following event, which should be 1, 2, or 3. If there is nofollowing event, this represents the press of any button.If the mouse is moved with a button pressed, theButton event is delivered in combination with a Motion eventso long as the button remains pressed..TP.B ButtonReleaseLike.BR ButtonPress ,but represents the release of any button..TP.B MotionMouse movement..TP.B DoubleAny events in the sequence representing button presses mustbe double-clicked for the sequence to match..TP.B MapThe event that a toplevel widget is mapped onto the screen..TP.B UnmapThe event that a toplevel widget is unmapped from the screen..TP.B EnterThe event of the mouse entering the widget from outside..TP.B LeaveThe event of the mouse leaving the boundaries of the widget..TP.B FocusInThe event of the widget getting the keyboard focus..TP.B FocusOutThe event of the widget losing the keyboard focus..REThe event sequence can contain any combination of the aboveevents. They are treated independently, and if any of theevents occur, the sequence matches. You cannot combinekey presses of more than one key. Events will not be combinedon delivery, except that.B Motionevents may be combined with button presses (possibly doubled)..TP.B DestroyThe event of the widget being destroyed.See.IR destroy  (9)for details of widget destruction. .SH "BINDING SCRIPTS AND SUBSTITUTIONS"The \fIscript\fR argument to \f5bind\fR is a Tk script,which will be executed whenever the given event sequence occurs.If \fIscript\fR containsany \f5%\fR characters, then the script will not beexecuted directly.  Instead, a new script will begenerated by replacing each \f5%\fR, and the character followingit, with information from the current event.  The replacementdepends on the character following the \f5%\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 \f5%%\fR 5Replaced with a single percent..IP \f5%b\fR 5The number of the button that was pressed or released.  Valid onlyfor \f5ButtonPress\fR and \f5ButtonRelease\fR events..IP \f5%h\fR 5For.B Configureevents, this isthe old requested height of the widget..IP \f5%s\fR 5For mouse events, this is the logical OR of the mouse buttons;for keyboard events, it is the decimal value of the pressed character..IP \f5%w\fR 5For.B Configureevents, this is the old requested width of the widget..IP \f5%x\fR 5The x coordinate from the event, relative to the originof the toplevel window. Valid only for.BR Enter ,.BR Leave ,and mouse events..IP \f5%y\fR 5The y coordinate from the event, relative to the originof the toplevel window. Valid only for.BR Enter ,.BR Leave ,and mouse events..IP \f5%A\fR 5The ASCII character corresponding to a \f5Key\fP event..IP \f5%K\fR 5The pressed character for the event, as four hexadecimal digits.Valid only for \f5Key\fP events..IP \f5%W\fR 5The path name of the window to which the event was reported (the\fIwindow\fR field from the event).  Valid for all event types..IP \f5%X\fR 5Same as.B %xexcept that the screen coordinate system is used..IP \f5%Y\fR 5Same as.B %yexcept that the screen coordinate system is used..LPThe replacement string for a %-replacement is formatted as a properTk list element.This means that it will be surrounded with bracesif it contains spaces, or special characters such as \f5$\fR and\f5{\fR may be preceded by backslashes.This guarantees that the string will be passed through the Tkparser when the binding script is evaluated..SH BUGSThe above scheme is not ideal, and will probably be fixedin the future.Quoting is a mess - in particular, the quoting provided for the.B %Asubstitution does not work correctly when a quoted characteris re-interpreted by Tk..LPThe length of binding scripts is limited to128 characters.