| 1 |
# Copyright (c) 1992-1994 The Regents of the University of California. |
| 2 |
# Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 3 |
# See the file "license.terms" for information on usage and redistribution |
| 4 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 5 |
# |
| 6 |
# |
| 7 |
|
| 8 |
=head1 NAME |
| 9 |
|
| 10 |
Tk_CreateGenericHandler, Tk_DeleteGenericHandler - associate procedure callback with all X events |
| 11 |
|
| 12 |
=for category C Programming |
| 13 |
|
| 14 |
=head1 SYNOPSIS |
| 15 |
|
| 16 |
B<#include E<lt>tk.hE<gt>> |
| 17 |
|
| 18 |
B<Tk_CreateGenericHandler>(I<proc, clientData>) |
| 19 |
|
| 20 |
B<Tk_DeleteGenericHandler>(I<proc, clientData>) |
| 21 |
|
| 22 |
=head1 ARGUMENTS |
| 23 |
|
| 24 |
=over 4 |
| 25 |
|
| 26 |
=item Tk_GenericProc *proc (in) |
| 27 |
|
| 28 |
Procedure to invoke whenever any X event occurs on any display. |
| 29 |
|
| 30 |
=item ClientData clientData (in) |
| 31 |
|
| 32 |
Arbitrary one-word value to pass to I<proc>. |
| 33 |
|
| 34 |
=back |
| 35 |
|
| 36 |
=head1 DESCRIPTION |
| 37 |
|
| 38 |
B<Tk_CreateGenericHandler> arranges for I<proc> to be |
| 39 |
invoked in the future whenever any X event occurs. This mechanism is |
| 40 |
I<not> intended for dispatching X events on windows managed by Tk |
| 41 |
(you should use B<Tk_CreateEventHandler> for this purpose). |
| 42 |
B<Tk_CreateGenericHandler> is intended for other purposes, such |
| 43 |
as tracing X events, monitoring events on windows not owned by Tk, |
| 44 |
accessing X-related libraries that were not originally designed for |
| 45 |
use with Tk, and so on. |
| 46 |
|
| 47 |
The callback to I<proc> will be made by B<Tk_HandleEvent>; |
| 48 |
this mechanism only works in programs that dispatch events |
| 49 |
through B<Tk_HandleEvent> (or through other Tk procedures that |
| 50 |
call B<Tk_HandleEvent>, such as B<Tk_DoOneEvent> or |
| 51 |
B<Tk_MainLoop>). |
| 52 |
|
| 53 |
I<Proc> should have arguments and result that match the |
| 54 |
type B<Tk_GenericProc>: |
| 55 |
|
| 56 |
typedef int Tk_GenericProc( |
| 57 |
ClientData clientData, |
| 58 |
XEvent *eventPtr); |
| 59 |
|
| 60 |
The I<clientData> parameter to I<proc> is a copy of the I<clientData> |
| 61 |
argument given to B<Tk_CreateGenericHandler> when the callback |
| 62 |
was created. Typically, I<clientData> points to a data |
| 63 |
structure containing application-specific information about |
| 64 |
how to handle events. |
| 65 |
I<EventPtr> is a pointer to the X event. |
| 66 |
|
| 67 |
Whenever an X event is processed by B<Tk_HandleEvent>, I<proc> |
| 68 |
is called. The return value from I<proc> is normally 0. |
| 69 |
A non-zero return value indicates that the event is not to be handled |
| 70 |
further; that is, I<proc> has done all processing that is to be |
| 71 |
allowed for the event. |
| 72 |
|
| 73 |
If there are multiple generic event handlers, each one is called |
| 74 |
for each event, in the order in which they were established. |
| 75 |
|
| 76 |
B<Tk_DeleteGenericHandler> may be called to delete a |
| 77 |
previously-created generic event handler: it deletes each handler |
| 78 |
it finds that matches the I<proc> and I<clientData> arguments. If |
| 79 |
no such handler exists, then B<Tk_DeleteGenericHandler> returns |
| 80 |
without doing anything. Although Tk supports it, it's probably |
| 81 |
a bad idea to have more than one callback with the same |
| 82 |
I<proc> and I<clientData> arguments. |
| 83 |
|
| 84 |
Establishing a generic event handler does nothing to ensure that the |
| 85 |
process will actually receive the X events that the handler wants to |
| 86 |
process. |
| 87 |
For example, it is the caller's responsibility to invoke |
| 88 |
B<XSelectInput> to select the desired events, if that is necessary. |
| 89 |
|
| 90 |
=head1 KEYWORDS |
| 91 |
|
| 92 |
bind, callback, event, handler |