Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Tk / event.pod
CommitLineData
86530b38
AT
1# Copyright (c) 1996 Sun Microsystems, Inc.
2# See the file "license.terms" for information on usage and redistribution
3# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
4#
5#
6
7=head1 NAME
8
9Tk::event - Miscellaneous event facilities: define virtual events and generate events
10
11=for category Binding Events and Callbacks
12
13=head1 SYNOPSIS
14
15I<$widget>-E<gt>B<event>I<Action>(?I<arg, arg, ...>?);
16
17=head1 DESCRIPTION
18
19The B<event>I<Action> methods provides several facilities for dealing with
20window system events, such as defining virtual events and synthesizing
21events. Virtual events are shared by all widgets of the same
22B<MainWindow>. Different L<MainWindow|Tk::MainWindow>s can have different
23virtual event.
24
25The following methods are currently supported:
26
27=over 4
28
29=item I<$widget>-E<gt>B<eventAdd>(B<'E<lt>E<lt>>I<virtual>B<E<gt>E<gt>'>I<, sequence >?,I<sequence, ...>?)
30
31Associates the virtual event I<virtual> with the physical
32event sequence(s) given by the I<sequence> arguments, so that
33the virtual event will trigger whenever any one of the I<sequence>s
34occurs.
35I<Virtual> may be any string value and I<sequence> may have
36any of the values allowed for the I<sequence> argument to the
37L<bind|Tk::bind> method.
38If I<virtual> is already defined, the new physical event sequences
39add to the existing sequences for the event.
40
41=item I<$widget>-E<gt>B<eventDelete>(B<'E<lt>E<lt>>I<virtual>B<E<gt>E<gt>'> ?,I<sequence,> I<sequence, ...>?)
42
43Deletes each of the I<sequence>s from those associated with
44the virtual event given by I<virtual>.
45I<Virtual> may be any string value and I<sequence> may have
46any of the values allowed for the I<sequence> argument to the
47L<bind|Tk::bind> method.
48Any I<sequence>s not currently associated with I<virtual>
49are ignored.
50If no I<sequence> argument is provided, all physical event sequences
51are removed for I<virtual>, so that the virtual event will not
52trigger anymore.
53
54=item I<$widget>-E<gt>B<eventGenerate>(I<event> ?,I<option =E<gt> value, option =E<gt> value, ...>?)
55
56Generates a window event and arranges for it to be processed just as if
57it had come from the window system.
58I<$window> is a reference to the window for which the event
59will be generated.
60I<Event> provides a basic description of
61the event, such as B<E<lt>Shift-Button-2E<gt>> or B<E<lt>E<lt>PasteE<gt>E<gt>>.
62If I<Window> is empty the whole screen is meant, and coordinates
63are relative to the screen.
64I<Event> may have any of the forms allowed for the I<sequence>
65argument of the L<bind|Tk::bind> method except that it must consist
66of a single event pattern, not a sequence.
67I<Option-value> pairs may be used to specify additional
68attributes of the event, such as the x and y mouse position;
69see L<"EVENT FIELDS"> below. If the B<-when> option is not specified, the
70event is processed immediately: all of the handlers for the event
71will complete before the B<eventGenerate> method returns.
72If the B<-when> option is specified then it determines when the
73event is processed.
74
75=item I<$widget>-E<gt>B<eventInfo>(?'B<E<lt>E<lt>>I<virtual>B<E<gt>E<gt>'>?)
76
77Returns information about virtual events.
78If the B<E<lt>E<lt>>I<virtual>B<E<gt>E<gt>> argument is omitted, the return value
79is a list of all the virtual events that are currently defined.
80If B<E<lt>E<lt>>I<virtual>B<E<gt>E<gt>> is specified then the return value is
81a list whose elements are the physical event sequences currently
82defined for the given virtual event; if the virtual event is
83not defined then B<undef> is returned.
84
85=back
86
87=head1 EVENT FIELDS
88
89The following options are supported for the B<eventGenerate>
90method. These correspond to the ``%'' expansions
91allowed in binding callback for the L<bind|Tk::bind> method.
92
93=over 4
94
95=item B<-above> => I<window>
96
97I<Window> specifies the I<above> field for the event,
98either as a window path name or as an integer window id.
99Valid for B<Configure> events.
100Corresponds to the L<%a|Tk::bind/'a'> substitution for binding scripts.
101
102=item B<-borderwidth> => I<size>
103
104I<Size> must be a screen distance; it specifies the
105I<border_width> field for the event.
106Valid for B<Configure> events.
107Corresponds to the L<%B|Tk::bind/'B'> substitution for binding scripts.
108
109=item B<-button> => I<number>
110
111I<Number> must be an integer; it specifies the I<detail> field
112for a B<ButtonPress> or B<ButtonRelease> event, overriding
113any button number provided in the base I<event> argument.
114Corresponds to the L<%b|Tk::bind/'b'> substitution for binding scripts.
115
116=item B<-count> => I<number>
117
118I<Number> must be an integer; it specifies the I<count> field
119for the event. Valid for B<Expose> events.
120Corresponds to the L<%c|Tk::bind/'c'> substitution for binding scripts.
121
122=item B<-detail> => I<detail>
123
124I<Detail> specifies the I<detail> field for the event
125and must be one of the following:
126
127=over 8
128
129 NotifyAncestor NotifyNonlinearVirtual
130 NotifyDetailNone NotifyPointer
131 NotifyInferior NotifyPointerRoot
132 NotifyNonlinear NotifyVirtual
133
134Valid for B<Enter>, B<Leave>, B<FocusIn> and
135B<FocusOut> events.
136Corresponds to the L<%d|Tk::bind/'d'> substitution for binding scripts.
137
138=back
139
140=item B<-focus>I< boolean>
141
142I<Boolean> must be a boolean value; it specifies the I<focus>
143field for the event.
144Valid for B<Enter> and B<Leave> events.
145Corresponds to the L<%f|Tk::bind/'f'> substitution for binding scripts.
146
147=item B<-height>I< size>
148
149I<Size> must be a screen distance; it specifies the I<height>
150field for the event. Valid for B<Configure> events.
151Corresponds to the L<%h|Tk::bind/'h'> substitution for binding scripts.
152
153=item B<-keycode>I< number>
154
155I<Number> must be an integer; it specifies the I<keycode>
156field for the event.
157Valid for B<KeyPress> and B<KeyRelease> events.
158Corresponds to the L<%k|Tk::bind/'k'> substitution for binding scripts.
159
160=item B<-keysym>I< name>
161
162I<Name> must be the name of a valid keysym, such as B<g>,
163B<space>, or B<Return>; its corresponding
164keycode value is used as the I<keycode> field for event, overriding
165any detail specified in the base I<event> argument.
166Valid for B<KeyPress> and B<KeyRelease> events.
167Corresponds to the L<%K|Tk::bind/'K'> substitution for binding scripts.
168
169=item B<-mode>I< notify>
170
171I<Notify> specifies the I<mode> field for the event and must be
172one of B<NotifyNormal>, B<NotifyGrab>, B<NotifyUngrab>, or
173B<NotifyWhileGrabbed>.
174Valid for B<Enter>, B<Leave>, B<FocusIn>, and
175B<FocusOut> events.
176Corresponds to the L<%m|Tk::bind/'m'> substitution for binding scripts.
177
178=item B<-override>I< boolean>
179
180I<Boolean> must be a boolean value; it specifies the
181I<override_redirect> field for the event.
182Valid for B<Map>, B<Reparent>, and B<Configure> events.
183Corresponds to the L<%o|Tk::bind/'o'> substitution for binding scripts.
184
185=item B<-place>I< where>
186
187I<Where> specifies the I<place> field for the event; it must be
188either B<PlaceOnTop> or B<PlaceOnBottom>.
189Valid for B<Circulate> events.
190Corresponds to the L<%p|Tk::bind/'p'> substitution for binding scripts.
191
192=item B<-root>I< window>
193
194I<Window> must be either a window path name or an integer window
195identifier; it specifies the I<root> field for the event.
196Valid for B<KeyPress>, B<KeyRelease>, B<ButtonPress>,
197B<ButtonRelease>, B<Enter>, B<Leave>, and B<Motion>
198events.
199Corresponds to the L<%R|Tk::bind/'R'> substitution for binding scripts.
200
201=item B<-rootx>I< coord>
202
203I<Coord> must be a screen distance; it specifies the I<x_root>
204field for the event.
205Valid for B<KeyPress>, B<KeyRelease>, B<ButtonPress>,
206B<ButtonRelease>, B<Enter>, B<Leave>, and B<Motion>
207events. Corresponds to the L<%X|Tk::bind/'X'> substitution for binding scripts.
208
209=item B<-rooty>I< coord>
210
211I<Coord> must be a screen distance; it specifies the I<y_root>
212field for the event.
213Valid for B<KeyPress>, B<KeyRelease>, B<ButtonPress>,
214B<ButtonRelease>, B<Enter>, B<Leave>, and B<Motion>
215events.
216Corresponds to the L<%Y|Tk::bind/'Y'> substitution for binding scripts.
217
218=item B<-sendevent>I< boolean>
219
220B<Boolean> must be a boolean value; it specifies the I<send_event>
221field for the event. Valid for all events. Corresponds to the
222L<%E|Tk::bind/'E'> substitution for binding scripts.
223
224=item B<-serial>I< number>
225
226I<Number> must be an integer; it specifies the I<serial> field
227for the event. Valid for all events.
228Corresponds to the L<%#|Tk::bind/'#'> substitution for binding scripts.
229
230=item B<-state>I< state>
231
232I<State> specifies the I<state> field for the event.
233For B<KeyPress>, B<KeyRelease>, B<ButtonPress>,
234B<ButtonRelease>, B<Enter>, B<Leave>, and B<Motion> events
235it must be an integer value.
236For B<Visibility> events it must be one of B<VisibilityUnobscured>,
237B<VisibilityPartiallyObscured>, or B<VisibilityFullyObscured>.
238This option overrides any modifiers such as B<Meta> or B<Control>
239specified in the base I<event>.
240Corresponds to the L<%s|Tk::bind/'s'> substitution for binding scripts.
241
242=item B<-subwindow>I< window>
243
244I<Window> specifies the I<subwindow> field for the event, either
245as a path name for a Tk widget or as an integer window identifier.
246Valid for B<KeyPress>, B<KeyRelease>, B<ButtonPress>,
247B<ButtonRelease>, B<Enter>, B<Leave>, and B<Motion> events.
248Similar to L<%S|Tk::bind/'S'> substitution for binding scripts.
249
250=item B<-time>I< integer>
251
252I<Integer> must be an integer value; it specifies the I<time> field
253for the event.
254Valid for B<KeyPress>, B<KeyRelease>, B<ButtonPress>,
255B<ButtonRelease>, B<Enter>, B<Leave>, B<Motion>,
256and B<Property> events.
257Corresponds to the L<%t|Tk::bind/'t'> substitution for binding scripts.
258
259
260=item B<-warp>I< boolean>
261
262I<boolean> must be a boolean value; it specifies whether
263the screen pointer should be warped as well.
264Valid for B<KeyPress>, B<KeyRelease>, B<ButtonPress>,
265B<ButtonRelease>, and B<Motion> events.
266
267=item B<-width>I< size>
268
269I<Size> must be a screen distance; it specifies the I<width> field
270for the event.
271Valid for B<Configure> events.
272Corresponds to the L<%w|Tk::bind/'w'> substitution for binding scripts.
273
274=item B<-when>I< when>
275
276I<When> determines when the event will be processed; it must have one
277of the following values:
278
279=over 8
280
281=item B<now>
282
283Process the event immediately, before the command returns.
284This also happens if the B<-when> option is omitted.
285
286=item B<tail>
287
288Place the event on perl/Tk's event queue behind any events already
289queued for this application.
290
291=item B<head>
292
293Place the event at the front of perl/Tk's event queue, so that it
294will be handled before any other events already queued.
295
296=item B<mark>
297
298Place the event at the front of perl/Tk's event queue but behind any
299other events already queued with B<-when mark>.
300This option is useful when generating a series of events that should
301be processed in order but at the front of the queue.
302
303=back
304
305=item B<-x>I< coord>
306
307I<Coord> must be a screen distance; it specifies the I<x> field
308for the event.
309Valid for B<KeyPress>, B<KeyRelease>, B<ButtonPress>,
310B<ButtonRelease>, B<Motion>, B<Enter>, B<Leave>,
311B<Expose>, B<Configure>, B<Gravity>, and B<Reparent>
312events.
313Corresponds to the the L<%x|Tk::bind/'x'> substitution for binding scripts.
314If I<Window> is empty the coordinate is relative to the
315screen, and this option corresponds to the L<%X|Tk::bind/'X'> substitution
316for binding scripts.
317
318=item B<-y>I< coord>
319
320I<Coord> must be a screen distance; it specifies the I<y>
321field for the event.
322Valid for B<KeyPress>, B<KeyRelease>, B<ButtonPress>,
323B<ButtonRelease>, B<Motion>, B<Enter>, B<Leave>,
324B<Expose>, B<Configure>, B<Gravity>, and B<Reparent>
325events.
326Corresponds to the the L<%y|Tk::bind/'y'> substitution for binding scripts.
327If I<Window> is empty the coordinate is relative to the
328screen, and this option corresponds to the L<%Y|Tk::bind/'Y'> substitution
329for binding scripts.
330
331Any options that are not specified when generating an event are filled
332with the value 0, except for I<serial>, which is filled with the
333next X event serial number.
334
335=back
336
337=head1 VIRTUAL EVENT EXAMPLES
338
339In order for a virtual event binding to trigger, two things must
340happen. First, the virtual event must be defined with the
341B<eventAdd> method. Second, a binding must be created for
342the virtual event with the B<bind> method.
343Consider the following virtual event definitions:
344
345 $widget->eventAdd('<<Paste>>' => '<Control-y>');
346 $widget->eventAdd('<<Paste>>' => '<Button-2>');
347 $widget->eventAdd('<<Save>>' => '<Control-X><Control-S>');
348 $widget->eventAdd('<<Save>>' => '<Shift-F12>');
349
350In the B<bind> method, a virtual event can be bound like any other
351builtin event type as follows:
352
353 $entry->bind('Tk::Entry', '<<Paste>>' => sub {
354 $entry->Insert($entry->selectionGet) });
355
356The double angle brackets are used to specify that a virtual event is being
357bound. If the user types Control-y or presses button 2, or if
358a B<E<lt>E<lt>PasteE<gt>E<gt>> virtual event is synthesized with B<eventGenerate>,
359then the B<E<lt>E<lt>PasteE<gt>E<gt>> binding will be invoked.
360
361If a virtual binding has the exact same sequence as a separate
362physical binding, then the physical binding will take precedence.
363Consider the following example:
364
365 $mw->eventAdd('<<Paste>>' => '<Control-y>','<Meta-Control-y>');
366 $mw->bind('Tk::Entry', '<Control-y>' => sub{print 'Control-y'});
367 $mw->bind('Tk::Entry', '<<Paste>>' => sub{print 'Paste'});
368
369When the user types Control-y the B<E<lt>Control-yE<gt>> binding
370will be invoked, because a physical event is considered
371more specific than a virtual event, all other things being equal.
372However, when the user types Meta-Control-y the
373B<E<lt>E<lt>PasteE<gt>E<gt>> binding will be invoked, because the
374B<Meta> modifier in the physical pattern associated with the
375virtual binding is more specific than the B<E<lt>Control-y>E<gt> sequence for
376the physical event.
377
378Bindings on a virtual event may be created before the virtual event exists.
379Indeed, the virtual event never actually needs to be defined, for instance,
380on platforms where the specific virtual event would meaningless or
381ungeneratable.
382
383When a definition of a virtual event changes at run time, all windows
384will respond immediately to the new definition.
385Starting from the preceding example, if the following code is executed:
386
387 $entry->bind(ref($entry), '<Control-y>' => undef);
388 $entry->eventAdd('<<Paste>>' => '<Key-F6>');
389
390the behavior will change such in two ways. First, the shadowed
391B<E<lt>E<lt>PasteE<gt>E<gt>> binding will emerge.
392Typing Control-y will no longer invoke the B<E<lt>Control-yE<gt>> binding,
393but instead invoke the virtual event B<E<lt>E<lt>PasteE<gt>E<gt>>. Second,
394pressing the F6 key will now also invoke the B<E<lt>E<lt>PasteE<gt>E<gt>> binding.
395
396=head1 SEE ALSO
397
398L<Tk::bind|Tk::bind>
399L<Tk::callbacks|Tk::callbacks>
400
401=head1 KEYWORDS
402
403event, binding, define, handle, virtual event
404
405=cut
406