1Tk_CreateGenericHandler(3)   Tk Library Procedures  Tk_CreateGenericHandler(3)
2
3
4
5______________________________________________________________________________
6

NAME

8       Tk_CreateGenericHandler,  Tk_DeleteGenericHandler - associate procedure
9       callback with all X events
10

SYNOPSIS

12       #include <tk.h>
13
14       Tk_CreateGenericHandler(proc, clientData)
15
16       Tk_DeleteGenericHandler(proc, clientData)
17

ARGUMENTS

19       Tk_GenericProc *proc (in)               Procedure  to  invoke  whenever
20                                               any  X event occurs on any dis‐
21                                               play.
22
23       ClientData clientData (in)              Arbitrary  one-word  value   to
24                                               pass to proc.
25______________________________________________________________________________
26

DESCRIPTION

28       Tk_CreateGenericHandler  arranges  for proc to be invoked in the future
29       whenever any X event occurs.  This mechanism is not intended  for  dis‐
30       patching  X  events  on  windows  managed by Tk (you should use Tk_Cre‐
31       ateEventHandler for this purpose).  Tk_CreateGenericHandler is intended
32       for other purposes, such as tracing X events, monitoring events on win‐
33       dows not owned by Tk, accessing X-related libraries that were not orig‐
34       inally designed for use with Tk, and so on.
35
36       The  callback  to  proc  will be made by Tk_HandleEvent; this mechanism
37       only works in programs that dispatch events through Tk_HandleEvent  (or
38       through   other   Tk  procedures  that  call  Tk_HandleEvent,  such  as
39       Tcl_DoOneEvent or Tk_MainLoop).
40
41       Proc should have arguments and result that  match  the  type  Tk_Gener‐
42       icProc:
43              typedef int Tk_GenericProc(
44                      ClientData clientData,
45                      XEvent *eventPtr);
46       The  clientData  parameter to proc is a copy of the clientData argument
47       given to Tk_CreateGenericHandler when the callback was created.   Typi‐
48       cally,  clientData  points  to a data structure containing application-
49       specific information about how to handle events.  EventPtr is a pointer
50       to the X event.
51
52       Whenever  an  X  event  is processed by Tk_HandleEvent, proc is called.
53       The return value from proc is normally 0.  A non-zero return value  in‐
54       dicates  that the event is not to be handled further; that is, proc has
55       done all processing that is to be allowed for the event.
56
57       If there are multiple generic event handlers, each one  is  called  for
58       each event, in the order in which they were established.
59
60       Tk_DeleteGenericHandler  may  be  called to delete a previously-created
61       generic event handler:  it deletes each handler it finds  that  matches
62       the  proc  and  clientData  arguments.  If no such handler exists, then
63       Tk_DeleteGenericHandler returns without doing  anything.   Although  Tk
64       supports  it,  it's  probably a bad idea to have more than one callback
65       with the same proc and clientData arguments.
66
67       Establishing a generic event handler does nothing to  ensure  that  the
68       process  will  actually  receive the X events that the handler wants to
69       process.  For example, it is the caller's responsibility to invoke XSe‐
70       lectInput to select the desired events, if that is necessary.
71

KEYWORDS

73       bind, callback, event, handler
74
75
76
77Tk                                                  Tk_CreateGenericHandler(3)
Impressum