| 1 |
578 |
markom |
'\"
|
| 2 |
|
|
'\" Copyright (c) 1992-1994 The Regents of the University of California.
|
| 3 |
|
|
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
|
| 4 |
|
|
'\"
|
| 5 |
|
|
'\" See the file "license.terms" for information on usage and redistribution
|
| 6 |
|
|
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 7 |
|
|
'\"
|
| 8 |
|
|
'\" RCS: @(#) $Id: CrtGenHdlr.3,v 1.1.1.1 2002-01-16 10:25:48 markom Exp $
|
| 9 |
|
|
'\"
|
| 10 |
|
|
.so man.macros
|
| 11 |
|
|
.TH Tk_CreateGenericHandler 3 "" Tk "Tk Library Procedures"
|
| 12 |
|
|
.BS
|
| 13 |
|
|
.SH NAME
|
| 14 |
|
|
Tk_CreateGenericHandler, Tk_DeleteGenericHandler \- associate procedure callback with all X events
|
| 15 |
|
|
.SH SYNOPSIS
|
| 16 |
|
|
.nf
|
| 17 |
|
|
\fB#include \fR
|
| 18 |
|
|
.sp
|
| 19 |
|
|
\fBTk_CreateGenericHandler\fR(\fIproc, clientData\fR)
|
| 20 |
|
|
.sp
|
| 21 |
|
|
\fBTk_DeleteGenericHandler\fR(\fIproc, clientData\fR)
|
| 22 |
|
|
.SH ARGUMENTS
|
| 23 |
|
|
.AS "Tk_GenericProc" clientData
|
| 24 |
|
|
.AP Tk_GenericProc *proc in
|
| 25 |
|
|
Procedure to invoke whenever any X event occurs on any display.
|
| 26 |
|
|
.AP ClientData clientData in
|
| 27 |
|
|
Arbitrary one-word value to pass to \fIproc\fR.
|
| 28 |
|
|
.BE
|
| 29 |
|
|
|
| 30 |
|
|
.SH DESCRIPTION
|
| 31 |
|
|
.PP
|
| 32 |
|
|
\fBTk_CreateGenericHandler\fR arranges for \fIproc\fR to be
|
| 33 |
|
|
invoked in the future whenever any X event occurs. This mechanism is
|
| 34 |
|
|
\fInot\fR intended for dispatching X events on windows managed by Tk
|
| 35 |
|
|
(you should use \fBTk_CreateEventHandler\fR for this purpose).
|
| 36 |
|
|
\fBTk_CreateGenericHandler\fR is intended for other purposes, such
|
| 37 |
|
|
as tracing X events, monitoring events on windows not owned by Tk,
|
| 38 |
|
|
accessing X-related libraries that were not originally designed for
|
| 39 |
|
|
use with Tk, and so on.
|
| 40 |
|
|
.PP
|
| 41 |
|
|
The callback to \fIproc\fR will be made by \fBTk_HandleEvent\fR;
|
| 42 |
|
|
this mechanism only works in programs that dispatch events
|
| 43 |
|
|
through \fBTk_HandleEvent\fR (or through other Tk procedures that
|
| 44 |
|
|
call \fBTk_HandleEvent\fR, such as \fBTk_DoOneEvent\fR or
|
| 45 |
|
|
\fBTk_MainLoop\fR).
|
| 46 |
|
|
.PP
|
| 47 |
|
|
\fIProc\fR should have arguments and result that match the
|
| 48 |
|
|
type \fBTk_GenericProc\fR:
|
| 49 |
|
|
.CS
|
| 50 |
|
|
typedef int Tk_GenericProc(
|
| 51 |
|
|
ClientData \fIclientData\fR,
|
| 52 |
|
|
XEvent *\fIeventPtr\fR);
|
| 53 |
|
|
.CE
|
| 54 |
|
|
The \fIclientData\fR parameter to \fIproc\fR is a copy of the \fIclientData\fR
|
| 55 |
|
|
argument given to \fBTk_CreateGenericHandler\fR when the callback
|
| 56 |
|
|
was created. Typically, \fIclientData\fR points to a data
|
| 57 |
|
|
structure containing application-specific information about
|
| 58 |
|
|
how to handle events.
|
| 59 |
|
|
\fIEventPtr\fR is a pointer to the X event.
|
| 60 |
|
|
.PP
|
| 61 |
|
|
Whenever an X event is processed by \fBTk_HandleEvent\fR, \fIproc\fR
|
| 62 |
|
|
is called. The return value from \fIproc\fR is normally 0.
|
| 63 |
|
|
A non-zero return value indicates that the event is not to be handled
|
| 64 |
|
|
further; that is, \fIproc\fR has done all processing that is to be
|
| 65 |
|
|
allowed for the event.
|
| 66 |
|
|
.PP
|
| 67 |
|
|
If there are multiple generic event handlers, each one is called
|
| 68 |
|
|
for each event, in the order in which they were established.
|
| 69 |
|
|
.PP
|
| 70 |
|
|
\fBTk_DeleteGenericHandler\fR may be called to delete a
|
| 71 |
|
|
previously-created generic event handler: it deletes each handler
|
| 72 |
|
|
it finds that matches the \fIproc\fR and \fIclientData\fR arguments. If
|
| 73 |
|
|
no such handler exists, then \fBTk_DeleteGenericHandler\fR returns
|
| 74 |
|
|
without doing anything. Although Tk supports it, it's probably
|
| 75 |
|
|
a bad idea to have more than one callback with the same
|
| 76 |
|
|
\fIproc\fR and \fIclientData\fR arguments.
|
| 77 |
|
|
.PP
|
| 78 |
|
|
Establishing a generic event handler does nothing to ensure that the
|
| 79 |
|
|
process will actually receive the X events that the handler wants to
|
| 80 |
|
|
process.
|
| 81 |
|
|
For example, it is the caller's responsibility to invoke
|
| 82 |
|
|
\fBXSelectInput\fR to select the desired events, if that is necessary.
|
| 83 |
|
|
.SH KEYWORDS
|
| 84 |
|
|
bind, callback, event, handler
|