Debian Codegraph @

pod/pTk/EventHndlr.pod

raw
1 # Copyright (c) 1990 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_CreateEventHandler, Tk_DeleteEventHandler - associate procedure callback with an X event
11
12 =for category C Programming
13
14 =head1 SYNOPSIS
15
16 B<#include E<lt>tk.hE<gt>>
17
18 B<Tk_CreateEventHandler>(I<tkwin, mask, proc, clientData>)
19
20 B<Tk_DeleteEventHandler>(I<tkwin, mask, proc, clientData>)
21
22 =head1 ARGUMENTS
23
24 =over 4
25
26 =item Tk_Window tkwin (in)
27
28 Token for window in which events may occur.
29
30 =item "unsigned long" mask (in)
31
32 Bit-mask of events (such as B<ButtonPressMask>)
33 for which I<proc> should be called.
34
35 =item Tk_EventProc *proc (in)
36
37 Procedure to invoke whenever an event in I<mask> occurs
38 in the window given by I<tkwin>.
39
40 =item ClientData clientData (in)
41
42 Arbitrary one-word value to pass to I<proc>.
43
44 =back
45
46 =head1 DESCRIPTION
47
48 B<Tk_CreateEventHandler> arranges for I<proc> to be
49 invoked in the future whenever one of the event types specified
50 by I<mask> occurs in the window specified by I<tkwin>.
51 The callback to I<proc> will be made by B<Tk_HandleEvent>;
52 this mechanism only works in programs that dispatch events
53 through B<Tk_HandleEvent> (or through other Tk procedures that
54 call B<Tk_HandleEvent>, such as B<Tk_DoOneEvent> or
55 B<Tk_MainLoop>).
56
57 I<Proc> should have arguments and result that match the
58 type B<Tk_EventProc>:
59
60 typedef void Tk_EventProc(
61 ClientData clientData,
62 XEvent *eventPtr);
63
64 The I<clientData> parameter to I<proc> is a copy of the I<clientData>
65 argument given to B<Tk_CreateEventHandler> when the callback
66 was created. Typically, I<clientData> points to a data
67 structure containing application-specific information about
68 the window in which the event occurred. I<EventPtr> is
69 a pointer to the X event, which will be one of the ones
70 specified in the I<mask> argument to B<Tk_CreateEventHandler>.
71
72 B<Tk_DeleteEventHandler> may be called to delete a
73 previously-created event handler: it deletes the first handler
74 it finds that is associated with I<tkwin> and matches the
75 I<mask>, I<proc>, and I<clientData> arguments. If
76 no such handler exists, then B<Tk_EventHandler> returns
77 without doing anything. Although Tk supports it, it's probably
78 a bad idea to have more than one callback with the same I<mask>,
79 I<proc>, and I<clientData> arguments.
80 When a window is deleted all of its handlers will be deleted
81 automatically; in this case there is no need to call
82 B<Tk_DeleteEventHandler>.
83
84 If multiple handlers are declared for the same type of X event
85 on the same window, then the handlers will be invoked in the
86 order they were created.
87
88 =head1 KEYWORDS
89
90 bind, callback, event, handler