NAME
TkCreateGenericHandler, TkDeleteGenericHandler - associate procedure
callback with all X eventsSYNOPSIS
##iinncclluuddee <
TTkkCCrreeaatteeGGeenneerriiccHHaannddlleerr(proc, clientData) TTkkDDeelleetteeGGeenneerriiccHHaannddlleerr(proc, clientData) AARRGGUUMMEENNTTSS TkGenericProc *proc (in) Procedure to invoke whenever> any X event occurs on any dis-
play.ClientData clientData (in) Arbitrary one-word value to
pass to proc.DESCRIPTION
TTkkCCrreeaatteeGGeenneerriiccHHaannddlleerr arranges for proc to be invoked in the futurewhenever any X event occurs. This mechanism is not intended for dis-
patching X events on windows managed by Tk (you should use TTkkCCrree-
aatteeEEvveennttHHaannddlleerr for this purpose). TTkkCCrreeaatteeGGeenneerriiccHHaannddlleerr is intendedfor other purposes, such as tracing X events, monitoring events on win-
dows not owned by Tk, accessing X-related libraries that were not orig-
inally designed for use with Tk, and so on. The callback to proc will be made by TTkkHHaannddlleeEEvveenntt; this mechanism only works in programs that dispatch events through TTkkHHaannddlleeEEvveenntt (or through other Tk procedures that call TTkkHHaannddlleeEEvveenntt, such as TTkkDDooOOnneeEEvveenntt or TTkkMMaaiinnLLoooopp).Proc should have arguments and result that match the type TTkkGGeenneerr-
iiccPPrroocc: typedef int TkGenericProc( ClientData clientData, XEvent *eventPtr); The clientData parameter to proc is a copy of the clientData argumentgiven to TTkkCCrreeaatteeGGeenneerriiccHHaannddlleerr when the callback was created. Typi-
cally, 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 TTkkHHaannddlleeEEvveenntt, 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.TTkkDDeelleetteeGGeenneerriiccHHaannddlleerr 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 TTkkDDeelleetteeGGeenneerriiccHHaannddlleerr 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 toprocess. For example, it is the caller's responsibility to invoke XXSSee-
lleeccttIInnppuutt to select the desired events, if that is necessary. KKEEYYWWOORRDDSS bind, callback, event, handler Tk TkCreateGenericHandler(3)