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

NAME

8       Tk_CreateEventHandler,   Tk_DeleteEventHandler  -  associate  procedure
9       callback with an X event
10

SYNOPSIS

12       #include <tk.h>
13
14       Tk_CreateEventHandler(tkwin, mask, proc, clientData)
15
16       Tk_DeleteEventHandler(tkwin, mask, proc, clientData)
17

ARGUMENTS

19       Tk_Window tkwin (in)                   Token for window in which events
20                                              may occur.
21
22       unsigned long mask (in)                Bit-mask of events (such as But‐
23                                              tonPressMask)  for  which   proc
24                                              should be called.
25
26       Tk_EventProc *proc (in)                Procedure  to invoke whenever an
27                                              event in mask occurs in the win‐
28                                              dow given by tkwin.
29
30       ClientData clientData (in)             Arbitrary one-word value to pass
31                                              to proc.
32______________________________________________________________________________
33

DESCRIPTION

35       Tk_CreateEventHandler arranges for proc to be  invoked  in  the  future
36       whenever  one of the event types specified by mask occurs in the window
37       specified by tkwin.  The callback to  proc  will  be  made  by  Tk_Han‐
38       dleEvent;  this  mechanism  only works in programs that dispatch events
39       through Tk_HandleEvent  (or  through  other  Tk  procedures  that  call
40       Tk_HandleEvent, such as Tcl_DoOneEvent or Tk_MainLoop).
41
42       Proc should have arguments and result that match the type Tk_EventProc:
43              typedef void Tk_EventProc(
44                      ClientData clientData,
45                      XEvent *eventPtr);
46       The  clientData  parameter to proc is a copy of the clientData argument
47       given to Tk_CreateEventHandler when the callback  was  created.   Typi‐
48       cally,  clientData  points  to a data structure containing application-
49       specific information about the window  in  which  the  event  occurred.
50       EventPtr  is  a  pointer  to the X event, which will be one of the ones
51       specified in the mask argument to Tk_CreateEventHandler.
52
53       Tk_DeleteEventHandler may be  called  to  delete  a  previously-created
54       event  handler:   it deletes the first handler it finds that is associ‐
55       ated with tkwin and matches the mask, proc, and  clientData  arguments.
56       If  no  such  handler exists, then Tk_HandleEvent returns without doing
57       anything.  Although Tk supports it, it's probably a bad  idea  to  have
58       more  than  one callback with the same mask, proc, and clientData argu‐
59       ments.  When a window is deleted all of its handlers  will  be  deleted
60       automatically;   in  this  case there is no need to call Tk_DeleteEven‐
61       tHandler.
62
63       If multiple handlers are declared for the same type of X event  on  the
64       same  window,  then the handlers will be invoked in the order they were
65       created.
66

KEYWORDS

68       bind, callback, event, handler
69
70
71
72Tk                                                    Tk_CreateEventHandler(3)
Impressum