.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "event 3pm" .TH event 3pm "2015-05-03" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Tk::event \- Miscellaneous event facilities: define virtual events and generate events .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fI\f(CI$widget\fI\fR\->\fBevent\fR\fIAction\fR(?\fIarg, arg, ...\fR?); .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \fBevent\fR\fIAction\fR methods provides several facilities for dealing with window system events, such as defining virtual events and synthesizing events. Virtual events are shared by all widgets of the same \&\fBMainWindow\fR. Different MainWindows can have different virtual event. .PP The following methods are currently supported: .IP "\fI\f(CI$widget\fI\fR\->\fBeventAdd\fR(\fB'<<\fR\fIvirtual\fR\fB>>'\fR\fI, sequence \fR?,\fIsequence, ...\fR?)" 4 .IX Item "$widget->eventAdd('<>', sequence ?,sequence, ...?)" Associates the virtual event \fIvirtual\fR with the physical event sequence(s) given by the \fIsequence\fR arguments, so that the virtual event will trigger whenever any one of the \fIsequence\fRs occurs. \&\fIVirtual\fR may be any string value and \fIsequence\fR may have any of the values allowed for the \fIsequence\fR argument to the bind method. If \fIvirtual\fR is already defined, the new physical event sequences add to the existing sequences for the event. .IP "\fI\f(CI$widget\fI\fR\->\fBeventDelete\fR(\fB'<<\fR\fIvirtual\fR\fB>>'\fR ?,\fIsequence,\fR \fIsequence, ...\fR?)" 4 .IX Item "$widget->eventDelete('<>' ?,sequence, sequence, ...?)" Deletes each of the \fIsequence\fRs from those associated with the virtual event given by \fIvirtual\fR. \&\fIVirtual\fR may be any string value and \fIsequence\fR may have any of the values allowed for the \fIsequence\fR argument to the bind method. Any \fIsequence\fRs not currently associated with \fIvirtual\fR are ignored. If no \fIsequence\fR argument is provided, all physical event sequences are removed for \fIvirtual\fR, so that the virtual event will not trigger anymore. .IP "\fI\f(CI$widget\fI\fR\->\fBeventGenerate\fR(\fIevent\fR ?,\fIoption => value, option => value, ...\fR?)" 4 .IX Item "$widget->eventGenerate(event ?,option => value, option => value, ...?)" Generates a window event and arranges for it to be processed just as if it had come from the window system. \&\fI\f(CI$window\fI\fR is a reference to the window for which the event will be generated. \&\fIEvent\fR provides a basic description of the event, such as \fB\fR or \fB<>\fR. If \fIWindow\fR is empty the whole screen is meant, and coordinates are relative to the screen. \&\fIEvent\fR may have any of the forms allowed for the \fIsequence\fR argument of the bind method except that it must consist of a single event pattern, not a sequence. \&\fIOption-value\fR pairs may be used to specify additional attributes of the event, such as the x and y mouse position; see \*(L"\s-1EVENT FIELDS\*(R"\s0 below. If the \fB\-when\fR option is not specified, the event is processed immediately: all of the handlers for the event will complete before the \fBeventGenerate\fR method returns. If the \fB\-when\fR option is specified then it determines when the event is processed. .IP "\fI\f(CI$widget\fI\fR\->\fBeventInfo\fR(?'\fB<<\fR\fIvirtual\fR\fB>>'\fR?)" 4 .IX Item "$widget->eventInfo(?'<>'?)" Returns information about virtual events. If the \fB<<\fR\fIvirtual\fR\fB>>\fR argument is omitted, the return value is a list of all the virtual events that are currently defined. If \fB<<\fR\fIvirtual\fR\fB>>\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 \fBundef\fR is returned. .SH "EVENT FIELDS" .IX Header "EVENT FIELDS" The following options are supported for the \fBeventGenerate\fR method. These correspond to the ``%'' expansions allowed in binding callback for the bind method. .IP "\fB\-above\fR => \fIwindow\fR" 4 .IX Item "-above => window" \&\fIWindow\fR specifies the \fIabove\fR field for the event, either as a window path name or as an integer window id. Valid for \fBConfigure\fR events. Corresponds to the \f(CW%a\fR substitution for binding scripts. .IP "\fB\-borderwidth\fR => \fIsize\fR" 4 .IX Item "-borderwidth => size" \&\fISize\fR must be a screen distance; it specifies the \&\fIborder_width\fR field for the event. Valid for \fBConfigure\fR events. Corresponds to the \f(CW%B\fR substitution for binding scripts. .IP "\fB\-button\fR => \fInumber\fR" 4 .IX Item "-button => number" \&\fINumber\fR must be an integer; it specifies the \fIdetail\fR field for a \fBButtonPress\fR or \fBButtonRelease\fR event, overriding any button number provided in the base \fIevent\fR argument. Corresponds to the \f(CW%b\fR substitution for binding scripts. .IP "\fB\-count\fR => \fInumber\fR" 4 .IX Item "-count => number" \&\fINumber\fR must be an integer; it specifies the \fIcount\fR field for the event. Valid for \fBExpose\fR events. Corresponds to the \f(CW%c\fR substitution for binding scripts. .IP "\fB\-delta\fR => \fInumber\fR" 4 .IX Item "-delta => number" \&\fBnumber\fR must be an integer; it specifies the \fBdelta\fR field for the \&\fBMouseWheel\fR event. The delta 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 \f(CW%D\fR substitution for binding scripts. .IP "\fB\-detail\fR => \fIdetail\fR" 4 .IX Item "-detail => detail" \&\fIDetail\fR specifies the \fIdetail\fR field for the event and must be one of the following: .RS 4 .Sp .Vb 4 \& NotifyAncestor NotifyNonlinearVirtual \& NotifyDetailNone NotifyPointer \& NotifyInferior NotifyPointerRoot \& NotifyNonlinear NotifyVirtual .Ve .RE .RS 4 .Sp Valid for \fBEnter\fR, \fBLeave\fR, \fBFocusIn\fR and \&\fBFocusOut\fR events. Corresponds to the \f(CW%d\fR substitution for binding scripts. .RE .IP "\fB\-focus\fR\fI boolean\fR" 4 .IX Item "-focus boolean" \&\fIBoolean\fR must be a boolean value; it specifies the \fIfocus\fR field for the event. Valid for \fBEnter\fR and \fBLeave\fR events. Corresponds to the \f(CW%f\fR substitution for binding scripts. .IP "\fB\-height\fR\fI size\fR" 4 .IX Item "-height size" \&\fISize\fR must be a screen distance; it specifies the \fIheight\fR field for the event. Valid for \fBConfigure\fR events. Corresponds to the \f(CW%h\fR substitution for binding scripts. .IP "\fB\-keycode\fR\fI number\fR" 4 .IX Item "-keycode number" \&\fINumber\fR must be an integer; it specifies the \fIkeycode\fR field for the event. Valid for \fBKeyPress\fR and \fBKeyRelease\fR events. Corresponds to the \f(CW%k\fR substitution for binding scripts. .IP "\fB\-keysym\fR\fI name\fR" 4 .IX Item "-keysym name" \&\fIName\fR must be the name of a valid keysym, such as \fBg\fR, \&\fBspace\fR, or \fBReturn\fR; its corresponding keycode value is used as the \fIkeycode\fR field for event, overriding any detail specified in the base \fIevent\fR argument. Valid for \fBKeyPress\fR and \fBKeyRelease\fR events. Corresponds to the \f(CW%K\fR substitution for binding scripts. .IP "\fB\-mode\fR\fI notify\fR" 4 .IX Item "-mode notify" \&\fINotify\fR specifies the \fImode\fR field for the event and must be one of \fBNotifyNormal\fR, \fBNotifyGrab\fR, \fBNotifyUngrab\fR, or \&\fBNotifyWhileGrabbed\fR. Valid for \fBEnter\fR, \fBLeave\fR, \fBFocusIn\fR, and \&\fBFocusOut\fR events. Corresponds to the \f(CW%m\fR substitution for binding scripts. .IP "\fB\-override\fR\fI boolean\fR" 4 .IX Item "-override boolean" \&\fIBoolean\fR must be a boolean value; it specifies the \&\fIoverride_redirect\fR field for the event. Valid for \fBMap\fR, \fBReparent\fR, and \fBConfigure\fR events. Corresponds to the \f(CW%o\fR substitution for binding scripts. .IP "\fB\-place\fR\fI where\fR" 4 .IX Item "-place where" \&\fIWhere\fR specifies the \fIplace\fR field for the event; it must be either \fBPlaceOnTop\fR or \fBPlaceOnBottom\fR. Valid for \fBCirculate\fR events. Corresponds to the \f(CW%p\fR substitution for binding scripts. .IP "\fB\-root\fR\fI window\fR" 4 .IX Item "-root window" \&\fIWindow\fR must be either a window path name or an integer window identifier; it specifies the \fIroot\fR field for the event. Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR, \&\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR events. Corresponds to the \f(CW%R\fR substitution for binding scripts. .IP "\fB\-rootx\fR\fI coord\fR" 4 .IX Item "-rootx coord" \&\fICoord\fR must be a screen distance; it specifies the \fIx_root\fR field for the event. Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR, \&\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR events. Corresponds to the \f(CW%X\fR substitution for binding scripts. .IP "\fB\-rooty\fR\fI coord\fR" 4 .IX Item "-rooty coord" \&\fICoord\fR must be a screen distance; it specifies the \fIy_root\fR field for the event. Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR, \&\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR events. Corresponds to the \f(CW%Y\fR substitution for binding scripts. .IP "\fB\-sendevent\fR\fI boolean\fR" 4 .IX Item "-sendevent boolean" \&\fBBoolean\fR must be a boolean value; it specifies the \fIsend_event\fR field for the event. Valid for all events. Corresponds to the \&\f(CW%E\fR substitution for binding scripts. .IP "\fB\-serial\fR\fI number\fR" 4 .IX Item "-serial number" \&\fINumber\fR must be an integer; it specifies the \fIserial\fR field for the event. Valid for all events. Corresponds to the %# substitution for binding scripts. .IP "\fB\-state\fR\fI state\fR" 4 .IX Item "-state state" \&\fIState\fR specifies the \fIstate\fR field for the event. For \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR, \&\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR events it must be an integer value. For \fBVisibility\fR events it must be one of \fBVisibilityUnobscured\fR, \&\fBVisibilityPartiallyObscured\fR, or \fBVisibilityFullyObscured\fR. This option overrides any modifiers such as \fBMeta\fR or \fBControl\fR specified in the base \fIevent\fR. Corresponds to the \f(CW%s\fR substitution for binding scripts. .IP "\fB\-subwindow\fR\fI window\fR" 4 .IX Item "-subwindow window" \&\fIWindow\fR specifies the \fIsubwindow\fR field for the event, either as a path name for a Tk widget or as an integer window identifier. Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR, \&\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR events. Similar to \f(CW%S\fR substitution for binding scripts. .IP "\fB\-time\fR\fI integer\fR" 4 .IX Item "-time integer" \&\fIInteger\fR must be an integer value; it specifies the \fItime\fR field for the event. Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR, \&\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, \fBMotion\fR, and \fBProperty\fR events. Corresponds to the \f(CW%t\fR substitution for binding scripts. .IP "\fB\-warp\fR\fI boolean\fR" 4 .IX Item "-warp boolean" \&\fIboolean\fR must be a boolean value; it specifies whether the screen pointer should be warped as well. Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR, \&\fBButtonRelease\fR, and \fBMotion\fR events. .IP "\fB\-width\fR\fI size\fR" 4 .IX Item "-width size" \&\fISize\fR must be a screen distance; it specifies the \fIwidth\fR field for the event. Valid for \fBConfigure\fR events. Corresponds to the \f(CW%w\fR substitution for binding scripts. .IP "\fB\-when\fR\fI when\fR" 4 .IX Item "-when when" \&\fIWhen\fR determines when the event will be processed; it must have one of the following values: .RS 4 .IP "\fBnow\fR" 8 .IX Item "now" Process the event immediately, before the command returns. This also happens if the \fB\-when\fR option is omitted. .IP "\fBtail\fR" 8 .IX Item "tail" Place the event on perl/Tk's event queue behind any events already queued for this application. .IP "\fBhead\fR" 8 .IX Item "head" Place the event at the front of perl/Tk's event queue, so that it will be handled before any other events already queued. .IP "\fBmark\fR" 8 .IX Item "mark" Place the event at the front of perl/Tk's event queue but behind any other events already queued with \fB\-when mark\fR. This option is useful when generating a series of events that should be processed in order but at the front of the queue. .RE .RS 4 .RE .IP "\fB\-x\fR\fI coord\fR" 4 .IX Item "-x coord" \&\fICoord\fR must be a screen distance; it specifies the \fIx\fR field for the event. Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR, \&\fBButtonRelease\fR, \fBMotion\fR, \fBEnter\fR, \fBLeave\fR, \&\fBExpose\fR, \fBConfigure\fR, \fBGravity\fR, and \fBReparent\fR events. Corresponds to the the \f(CW%x\fR substitution for binding scripts. If \fIWindow\fR is empty the coordinate is relative to the screen, and this option corresponds to the \f(CW%X\fR substitution for binding scripts. .IP "\fB\-y\fR\fI coord\fR" 4 .IX Item "-y coord" \&\fICoord\fR must be a screen distance; it specifies the \fIy\fR field for the event. Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR, \&\fBButtonRelease\fR, \fBMotion\fR, \fBEnter\fR, \fBLeave\fR, \&\fBExpose\fR, \fBConfigure\fR, \fBGravity\fR, and \fBReparent\fR events. Corresponds to the the \f(CW%y\fR substitution for binding scripts. If \fIWindow\fR is empty the coordinate is relative to the screen, and this option corresponds to the \f(CW%Y\fR substitution for binding scripts. .Sp Any options that are not specified when generating an event are filled with the value 0, except for \fIserial\fR, which is filled with the next X event serial number. .SH "VIRTUAL EVENT EXAMPLES" .IX Header "VIRTUAL EVENT EXAMPLES" In order for a virtual event binding to trigger, two things must happen. First, the virtual event must be defined with the \&\fBeventAdd\fR method. Second, a binding must be created for the virtual event with the \fBbind\fR method. Consider the following virtual event definitions: .PP .Vb 4 \& $widget\->eventAdd(\*(Aq<>\*(Aq => \*(Aq\*(Aq); \& $widget\->eventAdd(\*(Aq<>\*(Aq => \*(Aq\*(Aq); \& $widget\->eventAdd(\*(Aq<>\*(Aq => \*(Aq\*(Aq); \& $widget\->eventAdd(\*(Aq<>\*(Aq => \*(Aq\*(Aq); .Ve .PP In the \fBbind\fR method, a virtual event can be bound like any other builtin event type as follows: .PP .Vb 2 \& $entry\->bind(\*(AqTk::Entry\*(Aq, \*(Aq<>\*(Aq => sub { \& $entry\->Insert($entry\->selectionGet) }); .Ve .PP 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<>\fR virtual event is synthesized with \fBeventGenerate\fR, then the \fB<>\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: .PP .Vb 3 \& $mw\->eventAdd(\*(Aq<>\*(Aq => \*(Aq\*(Aq,\*(Aq\*(Aq); \& $mw\->bind(\*(AqTk::Entry\*(Aq, \*(Aq\*(Aq => sub{print \*(AqControl\-y\*(Aq}); \& $mw\->bind(\*(AqTk::Entry\*(Aq, \*(Aq<>\*(Aq => sub{print \*(AqPaste\*(Aq}); .Ve .PP When the user types Control-y the \fB\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<>\fR binding will be invoked, because the \&\fBMeta\fR modifier in the physical pattern associated with the virtual binding is more specific than the \fB 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: .PP .Vb 2 \& $entry\->bind(ref($entry), \*(Aq\*(Aq => undef); \& $entry\->eventAdd(\*(Aq<>\*(Aq => \*(Aq\*(Aq); .Ve .PP the behavior will change such in two ways. First, the shadowed \&\fB<>\fR binding will emerge. Typing Control-y will no longer invoke the \fB\fR binding, but instead invoke the virtual event \fB<>\fR. Second, pressing the F6 key will now also invoke the \fB<>\fR binding. .SH "SEE ALSO" .IX Header "SEE ALSO" Tk::bind Tk::callbacks .SH "KEYWORDS" .IX Header "KEYWORDS" event, binding, define, handle, virtual event