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

NAME

8       Tk_RestrictEvents - filter and selectively delay X events
9

SYNOPSIS

11       #include <tk.h>
12
13       Tk_RestrictProc *
14       Tk_RestrictEvents(proc, clientData, prevClientDataPtr)
15

ARGUMENTS

17       Tk_RestrictProc *proc (in)                        Predicate   procedure
18                                                         to  call  to   filter
19                                                         incoming   X  events.
20                                                         NULL  means  do   not
21                                                         restrict   events  at
22                                                         all.
23
24       ClientData clientData (in)                        Arbitrary argument to
25                                                         pass to proc.
26
27       ClientData *prevClientDataPtr (out)               Pointer  to  place to
28                                                         save argument to pre‐
29                                                         vious restrict proce‐
30                                                         dure.
31_________________________________________________________________
32
33

DESCRIPTION

35       This procedure is useful in certain situations where  applications  are
36       only  prepared to receive certain X events.  After Tk_RestrictEvents is
37       called, Tk_DoOneEvent (and  hence  Tk_MainLoop)  will  filter  X  input
38       events  through  proc.   Proc  indicates whether a given event is to be
39       processed immediately, deferred until some later time  (e.g.  when  the
40       event  restriction  is lifted), or discarded.  Proc is a procedure with
41       arguments and result that match the type Tk_RestrictProc:
42              typedef Tk_RestrictAction Tk_RestrictProc(
43                  ClientData clientData,
44                  XEvent *eventPtr);
45       The  clientData  argument  is  a  copy  of  the  clientData  passed  to
46       Tk_RestrictEvents;  it  may be used to provide proc with information it
47       needs to filter events.  The eventPtr points to an event under  consid‐
48       eration.   Proc  returns a restrict action (enumerated type Tk_Restric‐
49       tAction) that indicates what Tk_DoOneEvent should do  with  the  event.
50       If the return value is TK_PROCESS_EVENT, then the event will be handled
51       immediately.  If the return value is  TK_DEFER_EVENT,  then  the  event
52       will  be  left  on the event queue for later processing.  If the return
53       value is TK_DISCARD_EVENT, then the event  will  be  removed  from  the
54       event queue and discarded without being processed.
55
56       Tk_RestrictEvents uses its return value and prevClientDataPtr to return
57       information about the  current  event  restriction  procedure  (a  NULL
58       return  value means there are currently no restrictions).  These values
59       may be used to restore the previous restriction state when there is  no
60       longer any need for the current restriction.
61
62       There  are  very few places where Tk_RestrictEvents is needed.  In most
63       cases, the best way to restrict events is by changing the bindings with
64       the  bind  Tcl command or by calling Tk_CreateEventHandler and Tk_Dele‐
65       teEventHandler from C.  The main place where Tk_RestrictEvents must  be
66       used  is  when performing synchronous actions (for example, if you need
67       to wait for a particular event to occur on a particular window but  you
68       do  not  want to invoke any handlers for any other events).  The “obvi‐
69       ous” solution in these situations is to  call  XNextEvent  or  XWindow‐
70       Event,  but  these  procedures  cannot be used because Tk keeps its own
71       event queue that is separate from the X  event  queue.   Instead,  call
72       Tk_RestrictEvents  to  set  up  a  filter,  then  call Tk_DoOneEvent to
73       retrieve the desired event(s).
74

KEYWORDS

76       delay, event, filter, restriction
77
78
79
80Tk                                                        Tk_RestrictEvents(3)
Impressum