EventHndlr.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:3k
- '"
- '" Copyright (c) 1990 The Regents of the University of California.
- '" Copyright (c) 1994-1996 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: EventHndlr.3,v 1.4 1999/04/21 21:53:21 rjohnson Exp $
- '"
- .so man.macros
- .TH Tk_CreateEventHandler 3 "" Tk "Tk Library Procedures"
- .BS
- .SH NAME
- Tk_CreateEventHandler, Tk_DeleteEventHandler - associate procedure callback with an X event
- .SH SYNOPSIS
- .nf
- fB#include <tk.h>fR
- .sp
- fBTk_CreateEventHandlerfR(fItkwin, mask, proc, clientDatafR)
- .sp
- fBTk_DeleteEventHandlerfR(fItkwin, mask, proc, clientDatafR)
- .SH ARGUMENTS
- .AS "unsigned long" clientData
- .AP Tk_Window tkwin in
- Token for window in which events may occur.
- .AP "unsigned long" mask in
- Bit-mask of events (such as fBButtonPressMaskfR)
- for which fIprocfR should be called.
- .AP Tk_EventProc *proc in
- Procedure to invoke whenever an event in fImaskfR occurs
- in the window given by fItkwinfR.
- .AP ClientData clientData in
- Arbitrary one-word value to pass to fIprocfR.
- .BE
- .SH DESCRIPTION
- .PP
- fBTk_CreateEventHandlerfR arranges for fIprocfR to be
- invoked in the future whenever one of the event types specified
- by fImaskfR occurs in the window specified by fItkwinfR.
- The callback to fIprocfR will be made by fBTk_HandleEventfR;
- this mechanism only works in programs that dispatch events
- through fBTk_HandleEventfR (or through other Tk procedures that
- call fBTk_HandleEventfR, such as fBTk_DoOneEventfR or
- fBTk_MainLoopfR).
- .PP
- fIProcfR should have arguments and result that match the
- type fBTk_EventProcfR:
- .CS
- typedef void Tk_EventProc(
- ClientData fIclientDatafR,
- XEvent *fIeventPtrfR);
- .CE
- The fIclientDatafR parameter to fIprocfR is a copy of the fIclientDatafR
- argument given to fBTk_CreateEventHandlerfR when the callback
- was created. Typically, fIclientDatafR points to a data
- structure containing application-specific information about
- the window in which the event occurred. fIEventPtrfR is
- a pointer to the X event, which will be one of the ones
- specified in the fImaskfR argument to fBTk_CreateEventHandlerfR.
- .PP
- fBTk_DeleteEventHandlerfR may be called to delete a
- previously-created event handler: it deletes the first handler
- it finds that is associated with fItkwinfR and matches the
- fImaskfR, fIprocfR, and fIclientDatafR arguments. If
- no such handler exists, then fBTk_HandleEventfR returns
- without doing anything. Although Tk supports it, it's probably
- a bad idea to have more than one callback with the same fImaskfR,
- fIprocfR, and fIclientDatafR arguments.
- When a window is deleted all of its handlers will be deleted
- automatically; in this case there is no need to call
- fBTk_DeleteEventHandlerfR.
- .PP
- If multiple handlers are declared for the same type of X event
- on the same window, then the handlers will be invoked in the
- order they were created.
- .SH KEYWORDS
- bind, callback, event, handler