BINDING CALLBACKS AND SUBSTITUTIONS The *callback* argument to bind is a perl/Tk callback. which will +be executed whenever the given event sequence occurs. (See Tk::callba +cks for description of the possible forms.) *Callback* will be associa +ted with the same MainWindow that is associated with the *$widget* tha +t was used to invoke the bind method, and it will run as though called f +rom MainLoop. If *callback* contains any Ev(*%*) calls, then each "nes +ted" Ev(*%*) "callback" will be evaluated when the event occurs to form arguments to be passed to the main *callback*. The replacement dep +ends on the character *%*, as defined in the list below. Unless otherwi +se indicated, the replacement string is the numeric (decimal) value o +f the given field from the current event. Perl/Tk has enhanced this mech +anism slightly compared to the comparable Tcl/Tk mechanism. The enhancem +ents are not yet all reflected in the list below. Some of the substitut +ions are only valid for certain types of events; if they are used for o +ther types of events the value substituted is undefined (not the same a +s undef!). '#' The number of the last client request processed by the server +(the *serial* field from the event). Valid for all event types. 'a' The *above* field from the event, formatted as a hexadecimal n +umber. Valid only for Configure events. 'b' The number of the button that was pressed or released. Valid o +nly for ButtonPress and ButtonRelease events. 'c' The *count* field from the event. Valid only for Expose events +. 'd' The *detail* field from the event. The 'd' is replaced by a st +ring identifying the detail. For Enter, Leave, FocusIn, and FocusOu +t events, the string will be one of the following: NotifyAncestor NotifyNonlinearVirtual NotifyDetailNone NotifyPointer NotifyInferior NotifyPointerRoot NotifyNonlinear NotifyVirtual For ConfigureRequest events, the string will be one of: Above Opposite Below None BottomIf TopIf For events other than these, the substituted string is undefin +ed. (Note that this is *not* the same as Detail part of sequence u +se to specify the event.) 'f' The *focus* field from the event (0 or 1). Valid only for Ente +r and Leave events. 'h' The *height* field from the event. Valid only for Configure, ConfigureRequest, Create, Expose, and ResizeRequest events. 'i' The window field from the event, represented as a hexadecimal integer. 'k' The *keycode* field from the event. Valid only for KeyPress an +d KeyRelease events. 'm' The *mode* field from the event. The substituted string is one + of NotifyNormal, NotifyGrab, NotifyUngrab, or NotifyWhileGrabbed. + Valid only for Enter, FocusIn, FocusOut, and Leave events. 'o' The *override_redirect* field from the event. Valid only for M +ap, Reparent, and Configure events. 'p' The *place* field from the event, substituted as one of the st +rings PlaceOnTop or PlaceOnBottom. Valid only for Circulate and CirculateRequest events. 's' The *state* field from the event. For ButtonPress, ButtonRelea +se, Enter, KeyPress, KeyRelease, Leave, and Motion events, a decim +al string is substituted. For Visibility, one of the strings VisibilityUnobscured, VisibilityPartiallyObscured, and VisibilityFullyObscured is substituted. 't' The *time* field from the event. Valid only for events that co +ntain a *time* field. 'w' The *width* field from the event. Valid only for Configure, ConfigueRequest, Create, Expose, and ResizeREquest events. 'x' The *x* field from the event. Valid only for events containing + an *x* field. 'y' The *y* field from the event. Valid only for events containing + a *y* field. '@' The string "@*x,y*" where *x* and *y* are as above. Valid only + for events containing *x* and *y* fields. This format is used my m +ethods of Tk::Text and similar widgets. 'A' Substitutes the UNICODE character corresponding to the event, +or the empty string if the event doesn't correspond to a UNICODE char +acter (e.g. the shift key was pressed). XmbLookupString does all the + work of translating from the event to a UNICODE character. Valid on +ly for KeyPress and KeyRelease events. 'B' The *border_width* field from the event. Valid only for Config +ure, ConfigureRequest and Create events. 'D' This reports the delta value of a MouseWheel event. The delta +value represents the rotation units the mouse wheel has been moved. +On Windows 95 & 98 systems the smallest value for the delta is 12 +0. Future systems may support higher resolution values for the de +lta. The sign of the value represents the direction the mouse wheel + was scrolled. 'E' The *send_event* field from the event. Valid for all event typ +es. 'K' The keysym corresponding to the event, substituted as a textua +l string. Valid only for KeyPress and KeyRelease events. 'N' The keysym corresponding to the event, substituted as a decima +l number. Valid only for KeyPress and KeyRelease events. 'R' The *root* window identifier from the event. Valid only for ev +ents containing a *root* field. 'S' The *subwindow* window identifier from the event, as an object + if it is one otherwise as a hexadecimal number. Valid only for event +s containing a *subwindow* field. 'T' The *type* field from the event. Valid for all event types. 'W' The window to which the event was reported (the $widget field +from the event) - as an perl/Tk object. Valid for all event types. 'X' The *x_root* field from the event. If a virtual-root window ma +nager is being used then the substituted value is the corresponding x-coordinate in the virtual root. Valid only for ButtonPress, ButtonRelease, KeyPress, KeyRelease, and Motion events. 'Y' The *y_root* field from the event. If a virtual-root window ma +nager is being used then the substituted value is the corresponding y-coordinate in the virtual root. Valid only for ButtonPress, ButtonRelease, KeyPress, KeyRelease, and Motion events.
In reply to Re: I don't understand a piece of Perl/Tk code
by Anonymous Monk
in thread I don't understand a piece of Perl/Tk code
by spx2
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |