Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

tk_restrictevents(3tk) [debian man page]

Tk_RestrictEvents(3tk)					       Tk Library Procedures					    Tk_RestrictEvents(3tk)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_RestrictEvents - filter and selectively delay X events SYNOPSIS
#include <tk.h> Tk_RestrictProc * Tk_RestrictEvents(proc, clientData, prevClientDataPtr) ARGUMENTS
Tk_RestrictProc *proc (in) Predicate procedure to call to filter incoming X events. NULL means do not restrict events at all. ClientData clientData (in) Arbitrary argument to pass to proc. ClientData *prevClientDataPtr (out) Pointer to place to save argument to previous restrict procedure. _________________________________________________________________ DESCRIPTION
This procedure is useful in certain situations where applications are only prepared to receive certain X events. After Tk_RestrictEvents is called, Tk_DoOneEvent (and hence Tk_MainLoop) will filter X input events through proc. Proc indicates whether a given event is to be processed immediately, deferred until some later time (e.g. when the event restriction is lifted), or discarded. Proc is a procedure with arguments and result that match the type Tk_RestrictProc: typedef Tk_RestrictAction Tk_RestrictProc( ClientData clientData, XEvent *eventPtr); The clientData argument is a copy of the clientData passed to Tk_RestrictEvents; it may be used to provide proc with information it needs to filter events. The eventPtr points to an event under consideration. Proc returns a restrict action (enumerated type Tk_RestrictAction) that indicates what Tk_DoOneEvent should do with the event. If the return value is TK_PROCESS_EVENT, then the event will be handled imme- diately. If the return value is TK_DEFER_EVENT, then the event will be left on the event queue for later processing. If the return value is TK_DISCARD_EVENT, then the event will be removed from the event queue and discarded without being processed. Tk_RestrictEvents uses its return value and prevClientDataPtr to return information about the current event restriction procedure (a NULL return value means there are currently no restrictions). These values may be used to restore the previous restriction state when there is no longer any need for the current restriction. There are very few places where Tk_RestrictEvents is needed. In most cases, the best way to restrict events is by changing the bindings with the bind Tcl command or by calling Tk_CreateEventHandler and Tk_DeleteEventHandler from C. The main place where Tk_RestrictEvents must be used is when performing synchronous actions (for example, if you need to wait for a particular event to occur on a particular win- dow but you do not want to invoke any handlers for any other events). The "obvious" solution in these situations is to call XNextEvent or XWindowEvent, but these procedures cannot be used because Tk keeps its own event queue that is separate from the X event queue. Instead, call Tk_RestrictEvents to set up a filter, then call Tk_DoOneEvent to retrieve the desired event(s). KEYWORDS
delay, event, filter, restriction Tk Tk_RestrictEvents(3tk)

Check Out this Related Man Page

Tk_CreateGenericHandler(3tk)				       Tk Library Procedures				      Tk_CreateGenericHandler(3tk)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_CreateGenericHandler, Tk_DeleteGenericHandler - associate procedure callback with all X events SYNOPSIS
#include <tk.h> Tk_CreateGenericHandler(proc, clientData) Tk_DeleteGenericHandler(proc, clientData) ARGUMENTS
Tk_GenericProc *proc (in) Procedure to invoke whenever any X event occurs on any display. ClientData clientData (in) Arbitrary one-word value to pass to proc. _________________________________________________________________ DESCRIPTION
Tk_CreateGenericHandler arranges for proc to be invoked in the future whenever any X event occurs. This mechanism is not intended for dis- patching X events on windows managed by Tk (you should use Tk_CreateEventHandler for this purpose). Tk_CreateGenericHandler is intended for other purposes, such as tracing X events, monitoring events on windows not owned by Tk, accessing X-related libraries that were not originally designed for use with Tk, and so on. The callback to proc will be made by Tk_HandleEvent; this mechanism only works in programs that dispatch events through Tk_HandleEvent (or through other Tk procedures that call Tk_HandleEvent, such as Tk_DoOneEvent or Tk_MainLoop). Proc should have arguments and result that match the type Tk_GenericProc: typedef int Tk_GenericProc( ClientData clientData, XEvent *eventPtr); The clientData parameter to proc is a copy of the clientData argument given to Tk_CreateGenericHandler when the callback was created. Typ- ically, clientData points to a data structure containing application-specific information about how to handle events. EventPtr is a pointer to the X event. Whenever an X event is processed by Tk_HandleEvent, proc is called. The return value from proc is normally 0. A non-zero return value indicates that the event is not to be handled further; that is, proc has done all processing that is to be allowed for the event. If there are multiple generic event handlers, each one is called for each event, in the order in which they were established. Tk_DeleteGenericHandler may be called to delete a previously-created generic event handler: it deletes each handler it finds that matches the proc and clientData arguments. If no such handler exists, then Tk_DeleteGenericHandler returns without doing anything. Although Tk supports it, it's probably a bad idea to have more than one callback with the same proc and clientData arguments. Establishing a generic event handler does nothing to ensure that the process will actually receive the X events that the handler wants to process. For example, it is the caller's responsibility to invoke XSelectInput to select the desired events, if that is necessary. KEYWORDS
bind, callback, event, handler Tk Tk_CreateGenericHandler(3tk)
Man Page