home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>Tk::event - Miscellaneous event facilities: define virtual events and generate events</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tk::event - Miscellaneous event facilities: define virtual events and generate events</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#event fields">EVENT FIELDS</A></LI>
- <LI><A HREF="#virtual event examples">VIRTUAL EVENT EXAMPLES</A></LI>
- <LI><A HREF="#see also">SEE ALSO</A></LI>
- <LI><A HREF="#keywords">KEYWORDS</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>Tk::event - Miscellaneous event facilities: define virtual events and generate events</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <P><EM>$widget</EM>-><STRONG>event</STRONG><EM>Action</EM>(?<EM>arg, arg, ...</EM>?);</P>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>The <STRONG>event</STRONG><EM>Action</EM> 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
- <STRONG>MainWindow</STRONG>. Different <A HREF="../../../site/lib/Tk/MainWindow.html">MainWindow</A>s can have different
- virtual event.</P>
- <P>The following methods are currently supported:</P>
- <DL>
- <DT><STRONG><A NAME="item_eventAdd"><EM>$widget</EM>-><STRONG>eventAdd</STRONG>(<STRONG>'<<</STRONG><EM>virtual</EM><STRONG>>>'</STRONG><EM>, sequence </EM>?,<EM>sequence, ...</EM>?)</A></STRONG><BR>
- <DD>
- Associates the virtual event <EM>virtual</EM> with the physical
- event <CODE>sequence(s)</CODE> given by the <EM>sequence</EM> arguments, so that
- the virtual event will trigger whenever any one of the <EM>sequence</EM>s
- occurs.
- <EM>Virtual</EM> may be any string value and <EM>sequence</EM> may have
- any of the values allowed for the <EM>sequence</EM> argument to the
- <A HREF="../../../site/lib/Tk/bind.html">bind</A> method.
- If <EM>virtual</EM> is already defined, the new physical event sequences
- add to the existing sequences for the event.
- <P></P>
- <DT><STRONG><A NAME="item_eventDelete"><EM>$widget</EM>-><STRONG>eventDelete</STRONG>(<STRONG>'<<</STRONG><EM>virtual</EM><STRONG>>>'</STRONG> ?,<EM>sequence,</EM> <EM>sequence, ...</EM>?)</A></STRONG><BR>
- <DD>
- Deletes each of the <EM>sequence</EM>s from those associated with
- the virtual event given by <EM>virtual</EM>.
- <EM>Virtual</EM> may be any string value and <EM>sequence</EM> may have
- any of the values allowed for the <EM>sequence</EM> argument to the
- <A HREF="../../../site/lib/Tk/bind.html">bind</A> method.
- Any <EM>sequence</EM>s not currently associated with <EM>virtual</EM>
- are ignored.
- If no <EM>sequence</EM> argument is provided, all physical event sequences
- are removed for <EM>virtual</EM>, so that the virtual event will not
- trigger anymore.
- <P></P>
- <DT><STRONG><A NAME="item_eventGenerate"><EM>$widget</EM>-><STRONG>eventGenerate</STRONG>(<EM>event</EM> ?,<EM>option => value, option => value, ...</EM>?)</A></STRONG><BR>
- <DD>
- Generates a window event and arranges for it to be processed just as if
- it had come from the window system.
- <EM>$window</EM> is a reference to the window for which the event
- will be generated.
- <EM>Event</EM> provides a basic description of
- the event, such as <STRONG><Shift-Button-2></STRONG> or <STRONG><<Paste>></STRONG>.
- If <EM>Window</EM> is empty the whole screen is meant, and coordinates
- are relative to the screen.
- <EM>Event</EM> may have any of the forms allowed for the <EM>sequence</EM>
- argument of the <A HREF="../../../site/lib/Tk/bind.html">bind</A> method except that it must consist
- of a single event pattern, not a sequence.
- <EM>Option-value</EM> pairs may be used to specify additional
- attributes of the event, such as the x and y mouse position;
- see <A HREF="#event fields">EVENT FIELDS</A> below. If the <STRONG>-when</STRONG> option is not specified, the
- event is processed immediately: all of the handlers for the event
- will complete before the <STRONG>eventGenerate</STRONG> method returns.
- If the <STRONG>-when</STRONG> option is specified then it determines when the
- event is processed.
- <P></P>
- <DT><STRONG><A NAME="item_eventInfo"><EM>$widget</EM>-><STRONG>eventInfo</STRONG>(?'<STRONG><<</STRONG><EM>virtual</EM><STRONG>>>'</STRONG>?)</A></STRONG><BR>
- <DD>
- Returns information about virtual events.
- If the <STRONG><<</STRONG><EM>virtual</EM><STRONG>>></STRONG> argument is omitted, the return value
- is a list of all the virtual events that are currently defined.
- If <STRONG><<</STRONG><EM>virtual</EM><STRONG>>></STRONG> 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 <STRONG>undef</STRONG> is returned.
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="event fields">EVENT FIELDS</A></H1>
- <P>The following options are supported for the <STRONG>eventGenerate</STRONG>
- method. These correspond to the ``%'' expansions
- allowed in binding callback for the <A HREF="../../../site/lib/Tk/bind.html">bind</A> method.</P>
- <DL>
- <DT><STRONG><A NAME="item_%2Dabove_%3D%3E_window"><STRONG>-above</STRONG> => <EM>window</EM></A></STRONG><BR>
- <DD>
- <EM>Window</EM> specifies the <EM>above</EM> field for the event,
- either as a window path name or as an integer window id.
- Valid for <STRONG>Configure</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'a'">%a</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dborderwidth_%3D%3E_size"><STRONG>-borderwidth</STRONG> => <EM>size</EM></A></STRONG><BR>
- <DD>
- <EM>Size</EM> must be a screen distance; it specifies the
- <EM>border_width</EM> field for the event.
- Valid for <STRONG>Configure</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'b'">%B</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dbutton_%3D%3E_number"><STRONG>-button</STRONG> => <EM>number</EM></A></STRONG><BR>
- <DD>
- <EM>Number</EM> must be an integer; it specifies the <EM>detail</EM> field
- for a <STRONG>ButtonPress</STRONG> or <STRONG>ButtonRelease</STRONG> event, overriding
- any button number provided in the base <EM>event</EM> argument.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'b'">%b</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dcount_%3D%3E_number"><STRONG>-count</STRONG> => <EM>number</EM></A></STRONG><BR>
- <DD>
- <EM>Number</EM> must be an integer; it specifies the <EM>count</EM> field
- for the event. Valid for <STRONG>Expose</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'c'">%c</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Ddetail_%3D%3E_detail"><STRONG>-detail</STRONG> => <EM>detail</EM></A></STRONG><BR>
- <DD>
- <EM>Detail</EM> specifies the <EM>detail</EM> field for the event
- and must be one of the following:
- <PRE>
- NotifyAncestor NotifyNonlinearVirtual
- NotifyDetailNone NotifyPointer
- NotifyInferior NotifyPointerRoot
- NotifyNonlinear NotifyVirtual</PRE>
- <P>Valid for <STRONG>Enter</STRONG>, <STRONG>Leave</STRONG>, <STRONG>FocusIn</STRONG> and
- <STRONG>FocusOut</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'d'">%d</A> substitution for binding scripts.</P>
- <DT><STRONG><A NAME="item_%2Dfocus_boolean"><STRONG>-focus</STRONG><EM> boolean</EM></A></STRONG><BR>
- <DD>
- <EM>Boolean</EM> must be a boolean value; it specifies the <EM>focus</EM>
- field for the event.
- Valid for <STRONG>Enter</STRONG> and <STRONG>Leave</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'f'">%f</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dheight_size"><STRONG>-height</STRONG><EM> size</EM></A></STRONG><BR>
- <DD>
- <EM>Size</EM> must be a screen distance; it specifies the <EM>height</EM>
- field for the event. Valid for <STRONG>Configure</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'h'">%h</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dkeycode_number"><STRONG>-keycode</STRONG><EM> number</EM></A></STRONG><BR>
- <DD>
- <EM>Number</EM> must be an integer; it specifies the <EM>keycode</EM>
- field for the event.
- Valid for <STRONG>KeyPress</STRONG> and <STRONG>KeyRelease</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'k'">%k</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dkeysym_name"><STRONG>-keysym</STRONG><EM> name</EM></A></STRONG><BR>
- <DD>
- <EM>Name</EM> must be the name of a valid keysym, such as <STRONG>g</STRONG>,
- <STRONG>space</STRONG>, or <STRONG>Return</STRONG>; its corresponding
- keycode value is used as the <EM>keycode</EM> field for event, overriding
- any detail specified in the base <EM>event</EM> argument.
- Valid for <STRONG>KeyPress</STRONG> and <STRONG>KeyRelease</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'k'">%K</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dmode_notify"><STRONG>-mode</STRONG><EM> notify</EM></A></STRONG><BR>
- <DD>
- <EM>Notify</EM> specifies the <EM>mode</EM> field for the event and must be
- one of <STRONG>NotifyNormal</STRONG>, <STRONG>NotifyGrab</STRONG>, <STRONG>NotifyUngrab</STRONG>, or
- <STRONG>NotifyWhileGrabbed</STRONG>.
- Valid for <STRONG>Enter</STRONG>, <STRONG>Leave</STRONG>, <STRONG>FocusIn</STRONG>, and
- <STRONG>FocusOut</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'m'">%m</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Doverride_boolean"><STRONG>-override</STRONG><EM> boolean</EM></A></STRONG><BR>
- <DD>
- <EM>Boolean</EM> must be a boolean value; it specifies the
- <EM>override_redirect</EM> field for the event.
- Valid for <STRONG>Map</STRONG>, <STRONG>Reparent</STRONG>, and <STRONG>Configure</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'o'">%o</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dplace_where"><STRONG>-place</STRONG><EM> where</EM></A></STRONG><BR>
- <DD>
- <EM>Where</EM> specifies the <EM>place</EM> field for the event; it must be
- either <STRONG>PlaceOnTop</STRONG> or <STRONG>PlaceOnBottom</STRONG>.
- Valid for <STRONG>Circulate</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'p'">%p</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Droot_window"><STRONG>-root</STRONG><EM> window</EM></A></STRONG><BR>
- <DD>
- <EM>Window</EM> must be either a window path name or an integer window
- identifier; it specifies the <EM>root</EM> field for the event.
- Valid for <STRONG>KeyPress</STRONG>, <STRONG>KeyRelease</STRONG>, <STRONG>ButtonPress</STRONG>,
- <STRONG>ButtonRelease</STRONG>, <STRONG>Enter</STRONG>, <STRONG>Leave</STRONG>, and <STRONG>Motion</STRONG>
- events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'r'">%R</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Drootx_coord"><STRONG>-rootx</STRONG><EM> coord</EM></A></STRONG><BR>
- <DD>
- <EM>Coord</EM> must be a screen distance; it specifies the <EM>x_root</EM>
- field for the event.
- Valid for <STRONG>KeyPress</STRONG>, <STRONG>KeyRelease</STRONG>, <STRONG>ButtonPress</STRONG>,
- <STRONG>ButtonRelease</STRONG>, <STRONG>Enter</STRONG>, <STRONG>Leave</STRONG>, and <STRONG>Motion</STRONG>
- events. Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'x'">%X</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Drooty_coord"><STRONG>-rooty</STRONG><EM> coord</EM></A></STRONG><BR>
- <DD>
- <EM>Coord</EM> must be a screen distance; it specifies the <EM>y_root</EM>
- field for the event.
- Valid for <STRONG>KeyPress</STRONG>, <STRONG>KeyRelease</STRONG>, <STRONG>ButtonPress</STRONG>,
- <STRONG>ButtonRelease</STRONG>, <STRONG>Enter</STRONG>, <STRONG>Leave</STRONG>, and <STRONG>Motion</STRONG>
- events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'y'">%Y</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dsendevent_boolean"><STRONG>-sendevent</STRONG><EM> boolean</EM></A></STRONG><BR>
- <DD>
- <STRONG>Boolean</STRONG> must be a boolean value; it specifies the <EM>send_event</EM>
- field for the event. Valid for all events. Corresponds to the
- <A HREF="../../../site/lib/Tk/bind.html#'e'">%E</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dserial_number"><STRONG>-serial</STRONG><EM> number</EM></A></STRONG><BR>
- <DD>
- <EM>Number</EM> must be an integer; it specifies the <EM>serial</EM> field
- for the event. Valid for all events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'#'">%#</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dstate_state"><STRONG>-state</STRONG><EM> state</EM></A></STRONG><BR>
- <DD>
- <EM>State</EM> specifies the <EM>state</EM> field for the event.
- For <STRONG>KeyPress</STRONG>, <STRONG>KeyRelease</STRONG>, <STRONG>ButtonPress</STRONG>,
- <STRONG>ButtonRelease</STRONG>, <STRONG>Enter</STRONG>, <STRONG>Leave</STRONG>, and <STRONG>Motion</STRONG> events
- it must be an integer value.
- For <STRONG>Visibility</STRONG> events it must be one of <STRONG>VisibilityUnobscured</STRONG>,
- <STRONG>VisibilityPartiallyObscured</STRONG>, or <STRONG>VisibilityFullyObscured</STRONG>.
- This option overrides any modifiers such as <STRONG>Meta</STRONG> or <STRONG>Control</STRONG>
- specified in the base <EM>event</EM>.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'s'">%s</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dsubwindow_window"><STRONG>-subwindow</STRONG><EM> window</EM></A></STRONG><BR>
- <DD>
- <EM>Window</EM> specifies the <EM>subwindow</EM> field for the event, either
- as a path name for a Tk widget or as an integer window identifier.
- Valid for <STRONG>KeyPress</STRONG>, <STRONG>KeyRelease</STRONG>, <STRONG>ButtonPress</STRONG>,
- <STRONG>ButtonRelease</STRONG>, <STRONG>Enter</STRONG>, <STRONG>Leave</STRONG>, and <STRONG>Motion</STRONG> events.
- Similar to <A HREF="../../../site/lib/Tk/bind.html#'s'">%S</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dtime_integer"><STRONG>-time</STRONG><EM> integer</EM></A></STRONG><BR>
- <DD>
- <EM>Integer</EM> must be an integer value; it specifies the <EM>time</EM> field
- for the event.
- Valid for <STRONG>KeyPress</STRONG>, <STRONG>KeyRelease</STRONG>, <STRONG>ButtonPress</STRONG>,
- <STRONG>ButtonRelease</STRONG>, <STRONG>Enter</STRONG>, <STRONG>Leave</STRONG>, <STRONG>Motion</STRONG>,
- and <STRONG>Property</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'t'">%t</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dwarp_boolean"><STRONG>-warp</STRONG><EM> boolean</EM></A></STRONG><BR>
- <DD>
- <EM>boolean</EM> must be a boolean value; it specifies whether
- the screen pointer should be warped as well.
- Valid for <STRONG>KeyPress</STRONG>, <STRONG>KeyRelease</STRONG>, <STRONG>ButtonPress</STRONG>,
- <STRONG>ButtonRelease</STRONG>, and <STRONG>Motion</STRONG> events.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dwidth_size"><STRONG>-width</STRONG><EM> size</EM></A></STRONG><BR>
- <DD>
- <EM>Size</EM> must be a screen distance; it specifies the <EM>width</EM> field
- for the event.
- Valid for <STRONG>Configure</STRONG> events.
- Corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'w'">%w</A> substitution for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dwhen_when"><STRONG>-when</STRONG><EM> when</EM></A></STRONG><BR>
- <DD>
- <EM>When</EM> determines when the event will be processed; it must have one
- of the following values:
- <DL>
- <DT><STRONG><A NAME="item_now"><STRONG>now</STRONG></A></STRONG><BR>
- <DD>
- Process the event immediately, before the command returns.
- This also happens if the <STRONG>-when</STRONG> option is omitted.
- <P></P>
- <DT><STRONG><A NAME="item_tail"><STRONG>tail</STRONG></A></STRONG><BR>
- <DD>
- Place the event on perl/Tk's event queue behind any events already
- queued for this application.
- <P></P>
- <DT><STRONG><A NAME="item_head"><STRONG>head</STRONG></A></STRONG><BR>
- <DD>
- Place the event at the front of perl/Tk's event queue, so that it
- will be handled before any other events already queued.
- <P></P>
- <DT><STRONG><A NAME="item_mark"><STRONG>mark</STRONG></A></STRONG><BR>
- <DD>
- Place the event at the front of perl/Tk's event queue but behind any
- other events already queued with <STRONG>-when mark</STRONG>.
- This option is useful when generating a series of events that should
- be processed in order but at the front of the queue.
- <P></P></DL>
- <DT><STRONG><A NAME="item_%2Dx_coord"><STRONG>-x</STRONG><EM> coord</EM></A></STRONG><BR>
- <DD>
- <EM>Coord</EM> must be a screen distance; it specifies the <EM>x</EM> field
- for the event.
- Valid for <STRONG>KeyPress</STRONG>, <STRONG>KeyRelease</STRONG>, <STRONG>ButtonPress</STRONG>,
- <STRONG>ButtonRelease</STRONG>, <STRONG>Motion</STRONG>, <STRONG>Enter</STRONG>, <STRONG>Leave</STRONG>,
- <STRONG>Expose</STRONG>, <STRONG>Configure</STRONG>, <STRONG>Gravity</STRONG>, and <STRONG>Reparent</STRONG>
- events.
- Corresponds to the the <A HREF="../../../site/lib/Tk/bind.html#'x'">%x</A> substitution for binding scripts.
- If <EM>Window</EM> is empty the coordinate is relative to the
- screen, and this option corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'x'">%X</A> substitution
- for binding scripts.
- <P></P>
- <DT><STRONG><A NAME="item_%2Dy_coord"><STRONG>-y</STRONG><EM> coord</EM></A></STRONG><BR>
- <DD>
- <EM>Coord</EM> must be a screen distance; it specifies the <EM>y</EM>
- field for the event.
- Valid for <STRONG>KeyPress</STRONG>, <STRONG>KeyRelease</STRONG>, <STRONG>ButtonPress</STRONG>,
- <STRONG>ButtonRelease</STRONG>, <STRONG>Motion</STRONG>, <STRONG>Enter</STRONG>, <STRONG>Leave</STRONG>,
- <STRONG>Expose</STRONG>, <STRONG>Configure</STRONG>, <STRONG>Gravity</STRONG>, and <STRONG>Reparent</STRONG>
- events.
- Corresponds to the the <A HREF="../../../site/lib/Tk/bind.html#'y'">%y</A> substitution for binding scripts.
- If <EM>Window</EM> is empty the coordinate is relative to the
- screen, and this option corresponds to the <A HREF="../../../site/lib/Tk/bind.html#'y'">%Y</A> substitution
- for binding scripts.
- <P>Any options that are not specified when generating an event are filled
- with the value 0, except for <EM>serial</EM>, which is filled with the
- next X event serial number.</P>
- <P></P></DL>
- <P>
- <HR>
- <H1><A NAME="virtual event examples">VIRTUAL EVENT EXAMPLES</A></H1>
- <P>In order for a virtual event binding to trigger, two things must
- happen. First, the virtual event must be defined with the
- <STRONG>eventAdd</STRONG> method. Second, a binding must be created for
- the virtual event with the <STRONG>bind</STRONG> method.
- Consider the following virtual event definitions:</P>
- <PRE>
- $widget->eventAdd('<<Paste>>' => '<Control-y>');
- $widget->eventAdd('<<Paste>>' => '<Button-2>');
- $widget->eventAdd('<<Save>>' => '<Control-X><Control-S>');
- $widget->eventAdd('<<Save>>' => '<Shift-F12>');</PRE>
- <P>In the <STRONG>bind</STRONG> method, a virtual event can be bound like any other
- builtin event type as follows:</P>
- <PRE>
- $entry->bind('Tk::Entry', '<<Paste>>' => sub {
- $entry->Insert($entry->selectionGet) });</PRE>
- <P>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 <STRONG><<Paste>></STRONG> virtual event is synthesized with <STRONG>eventGenerate</STRONG>,
- then the <STRONG><<Paste>></STRONG> binding will be invoked.</P>
- <P>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:</P>
- <PRE>
- $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'});</PRE>
- <P>When the user types Control-y the <STRONG><Control-y></STRONG> 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
- <STRONG><<Paste>></STRONG> binding will be invoked, because the
- <STRONG>Meta</STRONG> modifier in the physical pattern associated with the
- virtual binding is more specific than the <STRONG><Control-y</STRONG>> sequence for
- the physical event.</P>
- <P>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.</P>
- <P>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:</P>
- <PRE>
- $entry->bind(ref($entry), '<Control-y>' => undef);
- $entry->eventAdd('<<Paste>>' => '<Key-F6>');</PRE>
- <P>the behavior will change such in two ways. First, the shadowed
- <STRONG><<Paste>></STRONG> binding will emerge.
- Typing Control-y will no longer invoke the <STRONG><Control-y></STRONG> binding,
- but instead invoke the virtual event <STRONG><<Paste>></STRONG>. Second,
- pressing the F6 key will now also invoke the <STRONG><<Paste>></STRONG> binding.</P>
- <P>
- <HR>
- <H1><A NAME="see also">SEE ALSO</A></H1>
- <P><A HREF="../../../site/lib/Tk/bind.html">Tk::bind</A>
- <A HREF="../../../site/lib/Tk/callbacks.html">Tk::callbacks</A></P>
- <P>
- <HR>
- <H1><A NAME="keywords">KEYWORDS</A></H1>
- <P>event, binding, define, handle, virtual event</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tk::event - Miscellaneous event facilities: define virtual events and generate events</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-