GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TK::EVENT (3)

.ds Aq ’

NAME

Tk::event - Miscellaneous event facilities: define virtual events and generate events

CONTENTS

SYNOPSIS

$widget-><B>eventB>Action(?arg, arg, ...?);

DESCRIPTION

The <B>eventB>Action 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 <B>MainWindowB>. Different MainWindows can have different virtual event.

The following methods are currently supported:
$widget-><B>eventAddB>(<B>’<<B>virtual<B>>>’B>, sequence ?,sequence, ...?) Associates the virtual event virtual with the physical event sequence(s) given by the sequence arguments, so that the virtual event will trigger whenever any one of the sequences occurs. Virtual may be any string value and sequence may have any of the values allowed for the sequence argument to the bind method. If virtual is already defined, the new physical event sequences add to the existing sequences for the event.
$widget-><B>eventDeleteB>(<B>’<<B>virtual<B>>>’B> ?,sequence, sequence, ...?) Deletes each of the sequences from those associated with the virtual event given by virtual. Virtual may be any string value and sequence may have any of the values allowed for the sequence argument to the bind method. Any sequences not currently associated with virtual are ignored. If no sequence argument is provided, all physical event sequences are removed for virtual, so that the virtual event will not trigger anymore.
$widget-><B>eventGenerateB>(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. $window is a reference to the window for which the event will be generated. Event provides a basic description of the event, such as <B><Shift-Button-2>B> or <B><<Paste>>B>. If Window is empty the whole screen is meant, and coordinates are relative to the screen. Event may have any of the forms allowed for the sequence argument of the bind method except that it must consist of a single event pattern, not a sequence. Option-value pairs may be used to specify additional attributes of the event, such as the x and y mouse position; see EVENT FIELDS below. If the <B>-whenB> option is not specified, the event is processed immediately: all of the handlers for the event will complete before the <B>eventGenerateB> method returns. If the <B>-whenB> option is specified then it determines when the event is processed.
$widget-><B>eventInfoB>(?’<B><<B>virtual<B>>>’B>?) Returns information about virtual events. If the <B><<B>virtual<B>>>B> argument is omitted, the return value is a list of all the virtual events that are currently defined. If <B><<B>virtual<B>>>B> 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 <B>undefB> is returned.

EVENT FIELDS

The following options are supported for the <B>eventGenerateB> method. These correspond to the ‘‘%’’ expansions allowed in binding callback for the bind method.
<B>-aboveB> => window Window specifies the above field for the event, either as a window path name or as an integer window id. Valid for <B>ConfigureB> events. Corresponds to the %a substitution for binding scripts.
<B>-borderwidthB> => size Size must be a screen distance; it specifies the border_width field for the event. Valid for <B>ConfigureB> events. Corresponds to the %B substitution for binding scripts.
<B>-buttonB> => number Number must be an integer; it specifies the detail field for a <B>ButtonPressB> or <B>ButtonReleaseB> event, overriding any button number provided in the base event argument. Corresponds to the %b substitution for binding scripts.
<B>-countB> => number Number must be an integer; it specifies the count field for the event. Valid for <B>ExposeB> events. Corresponds to the %c substitution for binding scripts.
<B>-deltaB> => number <B>numberB> must be an integer; it specifies the <B>deltaB> field for the <B>MouseWheelB> 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 %D substitution for binding scripts.
<B>-detailB> => detail Detail specifies the detail field for the event and must be one of the following:



 NotifyAncestor         NotifyNonlinearVirtual
 NotifyDetailNone       NotifyPointer
 NotifyInferior         NotifyPointerRoot
 NotifyNonlinear        NotifyVirtual



Valid for <B>EnterB>, <B>LeaveB>, <B>FocusInB> and <B>FocusOutB> events. Corresponds to the %d substitution for binding scripts.

<B>-focusB> boolean Boolean must be a boolean value; it specifies the focus field for the event. Valid for <B>EnterB> and <B>LeaveB> events. Corresponds to the %f substitution for binding scripts.
<B>-heightB> size Size must be a screen distance; it specifies the height field for the event. Valid for <B>ConfigureB> events. Corresponds to the %h substitution for binding scripts.
<B>-keycodeB> number Number must be an integer; it specifies the keycode field for the event. Valid for <B>KeyPressB> and <B>KeyReleaseB> events. Corresponds to the %k substitution for binding scripts.
<B>-keysymB> name Name must be the name of a valid keysym, such as <B>gB>, <B>spaceB>, or <B>ReturnB>; its corresponding keycode value is used as the keycode field for event, overriding any detail specified in the base event argument. Valid for <B>KeyPressB> and <B>KeyReleaseB> events. Corresponds to the %K substitution for binding scripts.
<B>-modeB> notify Notify specifies the mode field for the event and must be one of <B>NotifyNormalB>, <B>NotifyGrabB>, <B>NotifyUngrabB>, or <B>NotifyWhileGrabbedB>. Valid for <B>EnterB>, <B>LeaveB>, <B>FocusInB>, and <B>FocusOutB> events. Corresponds to the %m substitution for binding scripts.
<B>-overrideB> boolean Boolean must be a boolean value; it specifies the override_redirect field for the event. Valid for <B>MapB>, <B>ReparentB>, and <B>ConfigureB> events. Corresponds to the %o substitution for binding scripts.
<B>-placeB> where Where specifies the place field for the event; it must be either <B>PlaceOnTopB> or <B>PlaceOnBottomB>. Valid for <B>CirculateB> events. Corresponds to the %p substitution for binding scripts.
<B>-rootB> window Window must be either a window path name or an integer window identifier; it specifies the root field for the event. Valid for <B>KeyPressB>, <B>KeyReleaseB>, <B>ButtonPressB>, <B>ButtonReleaseB>, <B>EnterB>, <B>LeaveB>, and <B>MotionB> events. Corresponds to the %R substitution for binding scripts.
<B>-rootxB> coord Coord must be a screen distance; it specifies the x_root field for the event. Valid for <B>KeyPressB>, <B>KeyReleaseB>, <B>ButtonPressB>, <B>ButtonReleaseB>, <B>EnterB>, <B>LeaveB>, and <B>MotionB> events. Corresponds to the %X substitution for binding scripts.
<B>-rootyB> coord Coord must be a screen distance; it specifies the y_root field for the event. Valid for <B>KeyPressB>, <B>KeyReleaseB>, <B>ButtonPressB>, <B>ButtonReleaseB>, <B>EnterB>, <B>LeaveB>, and <B>MotionB> events. Corresponds to the %Y substitution for binding scripts.
<B>-sendeventB> boolean <B>BooleanB> must be a boolean value; it specifies the send_event field for the event. Valid for all events. Corresponds to the %E substitution for binding scripts.
<B>-serialB> number Number must be an integer; it specifies the serial field for the event. Valid for all events. Corresponds to the %# substitution for binding scripts.
<B>-stateB> state State specifies the state field for the event. For <B>KeyPressB>, <B>KeyReleaseB>, <B>ButtonPressB>, <B>ButtonReleaseB>, <B>EnterB>, <B>LeaveB>, and <B>MotionB> events it must be an integer value. For <B>VisibilityB> events it must be one of <B>VisibilityUnobscuredB>, <B>VisibilityPartiallyObscuredB>, or <B>VisibilityFullyObscuredB>. This option overrides any modifiers such as <B>MetaB> or <B>ControlB> specified in the base event. Corresponds to the %s substitution for binding scripts.
<B>-subwindowB> window Window specifies the subwindow field for the event, either as a path name for a Tk widget or as an integer window identifier. Valid for <B>KeyPressB>, <B>KeyReleaseB>, <B>ButtonPressB>, <B>ButtonReleaseB>, <B>EnterB>, <B>LeaveB>, and <B>MotionB> events. Similar to %S substitution for binding scripts.
<B>-timeB> integer Integer must be an integer value; it specifies the time field for the event. Valid for <B>KeyPressB>, <B>KeyReleaseB>, <B>ButtonPressB>, <B>ButtonReleaseB>, <B>EnterB>, <B>LeaveB>, <B>MotionB>, and <B>PropertyB> events. Corresponds to the %t substitution for binding scripts.
<B>-warpB> boolean boolean must be a boolean value; it specifies whether the screen pointer should be warped as well. Valid for <B>KeyPressB>, <B>KeyReleaseB>, <B>ButtonPressB>, <B>ButtonReleaseB>, and <B>MotionB> events.
<B>-widthB> size Size must be a screen distance; it specifies the width field for the event. Valid for <B>ConfigureB> events. Corresponds to the %w substitution for binding scripts.
<B>-whenB> when When determines when the event will be processed; it must have one of the following values:
<B>nowB> Process the event immediately, before the command returns. This also happens if the <B>-whenB> option is omitted.
<B>tailB> Place the event on perl/Tk’s event queue behind any events already queued for this application.
<B>headB> Place the event at the front of perl/Tk’s event queue, so that it will be handled before any other events already queued.
<B>markB> Place the event at the front of perl/Tk’s event queue but behind any other events already queued with <B>-when markB>. This option is useful when generating a series of events that should be processed in order but at the front of the queue.
<B>-xB> coord Coord must be a screen distance; it specifies the x field for the event. Valid for <B>KeyPressB>, <B>KeyReleaseB>, <B>ButtonPressB>, <B>ButtonReleaseB>, <B>MotionB>, <B>EnterB>, <B>LeaveB>, <B>ExposeB>, <B>ConfigureB>, <B>GravityB>, and <B>ReparentB> events. Corresponds to the the %x substitution for binding scripts. If Window is empty the coordinate is relative to the screen, and this option corresponds to the %X substitution for binding scripts.
<B>-yB> coord Coord must be a screen distance; it specifies the y field for the event. Valid for <B>KeyPressB>, <B>KeyReleaseB>, <B>ButtonPressB>, <B>ButtonReleaseB>, <B>MotionB>, <B>EnterB>, <B>LeaveB>, <B>ExposeB>, <B>ConfigureB>, <B>GravityB>, and <B>ReparentB> events. Corresponds to the the %y substitution for binding scripts. If Window is empty the coordinate is relative to the screen, and this option corresponds to the %Y substitution for binding scripts.

Any options that are not specified when generating an event are filled with the value 0, except for serial, which is filled with the next X event serial number.

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 <B>eventAddB> method. Second, a binding must be created for the virtual event with the <B>bindB> method. Consider the following virtual event definitions:



 $widget->eventAdd(<<Paste>> => <Control-y>);
 $widget->eventAdd(<<Paste>> => <Button-2>);
 $widget->eventAdd(<<Save>> => <Control-X><Control-S>);
 $widget->eventAdd(<<Save>> => <Shift-F12>);



In the <B>bindB> method, a virtual event can be bound like any other builtin event type as follows:



 $entry->bind(Tk::Entry, <<Paste>> => sub {
                $entry->Insert($entry->selectionGet) });



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 <B><<Paste>>B> virtual event is synthesized with <B>eventGenerateB>, then the <B><<Paste>>B> binding will be invoked.

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:



 $mw->eventAdd(<<Paste>> => <Control-y>,<Meta-Control-y>);
 $mw->bind(Tk::Entry, <Control-y> => sub{print Control-y});
 $mw->bind(Tk::Entry, <<Paste>>   => sub{print Paste});



When the user types Control-y the <B><Control-y>B> 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 <B><<Paste>>B> binding will be invoked, because the <B>MetaB> modifier in the physical pattern associated with the virtual binding is more specific than the <B><Control-yB>> sequence for the physical event.

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.

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:



 $entry->bind(ref($entry), <Control-y> => undef);
 $entry->eventAdd(<<Paste>> => <Key-F6>);



the behavior will change such in two ways. First, the shadowed <B><<Paste>>B> binding will emerge. Typing Control-y will no longer invoke the <B><Control-y>B> binding, but instead invoke the virtual event <B><<Paste>>B>. Second, pressing the F6 key will now also invoke the <B><<Paste>>B> binding.

SEE ALSO

Tk::bind Tk::callbacks

KEYWORDS

event, binding, define, handle, virtual event
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 EVENT (3) 2013-11-15

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.