Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/DoOneEvent.3 @ 25

Last change on this file since 25 was 25, checked in by landauf, 17 years ago

added tcl to libs

File size: 4.1 KB
Line 
1'\"
2'\" Copyright (c) 1990-1992 The Regents of the University of California.
3'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4'\"
5'\" See the file "license.terms" for information on usage and redistribution
6'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7'\"
8'\" RCS: @(#) $Id: DoOneEvent.3,v 1.6 2007/12/13 15:22:31 dgp Exp $
9'\"
10.so man.macros
11.TH Tcl_DoOneEvent 3 7.5 Tcl "Tcl Library Procedures"
12.BS
13.SH NAME
14Tcl_DoOneEvent \- wait for events and invoke event handlers
15.SH SYNOPSIS
16.nf
17\fB#include <tcl.h>\fR
18.sp
19int
20\fBTcl_DoOneEvent\fR(\fIflags\fR)
21.SH ARGUMENTS
22.AS int flags
23.AP int flags in
24This parameter is normally zero.  It may be an OR-ed combination
25of any of the following flag bits: 
26\fBTCL_WINDOW_EVENTS\fR, \fBTCL_FILE_EVENTS\fR,
27\fBTCL_TIMER_EVENTS\fR, \fBTCL_IDLE_EVENTS\fR, \fBTCL_ALL_EVENTS\fR,
28or \fBTCL_DONT_WAIT\fR.
29.BE
30
31.SH DESCRIPTION
32.PP
33This procedure is the entry point to Tcl's event loop; it is responsible for
34waiting for events and dispatching event handlers created with
35procedures such as \fBTk_CreateEventHandler\fR, \fBTcl_CreateFileHandler\fR,
36\fBTcl_CreateTimerHandler\fR, and \fBTcl_DoWhenIdle\fR.
37\fBTcl_DoOneEvent\fR checks to see if
38events are already present on the Tcl event queue; if so,
39it calls the handler(s) for the first (oldest) event, removes it from
40the queue, and returns.
41If there are no events ready to be handled, then \fBTcl_DoOneEvent\fR
42checks for new events from all possible sources.
43If any are found, it puts all of them on Tcl's event queue, calls
44handlers for the first event on the queue, and returns.
45If no events are found, \fBTcl_DoOneEvent\fR checks for \fBTcl_DoWhenIdle\fR
46callbacks; if any are found, it invokes all of them and returns.
47Finally, if no events or idle callbacks have been found, then
48\fBTcl_DoOneEvent\fR sleeps until an event occurs; then it adds any
49new events to the Tcl event queue, calls handlers for the first event,
50and returns.
51The normal return value is 1 to signify that some event
52was processed (see below for other alternatives).
53.PP
54If the \fIflags\fR argument to \fBTcl_DoOneEvent\fR is non-zero,
55it restricts the kinds of events that will be processed by
56\fBTcl_DoOneEvent\fR.
57\fIFlags\fR may be an OR-ed combination of any of the following bits:
58.TP 27
59\fBTCL_WINDOW_EVENTS\fR \-
60Process window system events.
61.TP 27
62\fBTCL_FILE_EVENTS\fR \-
63Process file events.
64.TP 27
65\fBTCL_TIMER_EVENTS\fR \-
66Process timer events.
67.TP 27
68\fBTCL_IDLE_EVENTS\fR \-
69Process idle callbacks.
70.TP 27
71\fBTCL_ALL_EVENTS\fR \-
72Process all kinds of events:  equivalent to OR-ing together all of the
73above flags or specifying none of them.
74.TP 27
75\fBTCL_DONT_WAIT\fR \-
76Do not sleep:  process only events that are ready at the time of the
77call.
78.LP
79If any of the flags \fBTCL_WINDOW_EVENTS\fR, \fBTCL_FILE_EVENTS\fR,
80\fBTCL_TIMER_EVENTS\fR, or \fBTCL_IDLE_EVENTS\fR is set, then the only
81events that will be considered are those for which flags are set.
82Setting none of these flags is equivalent to the value
83\fBTCL_ALL_EVENTS\fR, which causes all event types to be processed.
84If an application has defined additional event sources with
85\fBTcl_CreateEventSource\fR, then additional \fIflag\fR values
86may also be valid, depending on those event sources.
87.PP
88The \fBTCL_DONT_WAIT\fR flag causes \fBTcl_DoOneEvent\fR not to put
89the process to sleep:  it will check for events but if none are found
90then it returns immediately with a return value of 0 to indicate
91that no work was done.
92\fBTcl_DoOneEvent\fR will also return 0 without doing anything if
93the only alternative is to block forever (this can happen, for example,
94if \fIflags\fR is \fBTCL_IDLE_EVENTS\fR and there are no
95\fBTcl_DoWhenIdle\fR callbacks pending, or if no event handlers or
96timer handlers exist).
97.PP
98\fBTcl_DoOneEvent\fR may be invoked recursively.  For example,
99it is possible to invoke \fBTcl_DoOneEvent\fR recursively
100from a handler called by \fBTcl_DoOneEvent\fR.  This sort
101of operation is useful in some modal situations, such
102as when a
103notification dialog has been popped up and an application wishes to
104wait for the user to click a button in the dialog before
105doing anything else.
106
107.SH KEYWORDS
108callback, event, handler, idle, timer
Note: See TracBrowser for help on using the repository browser.