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