Tcl_DoOneEvent(3)
π Tcl_DoOneEvent β bestie, the event loop is CALLING β¨
okay so this is Tcl_DoOneEvent(3) from the Tcl Library Procedures, and no cap, she is the moment π
πΈ NAME πΈ
Tcl_DoOneEvent β sit around waiting for events, then run the handlers for them π
π SYNOPSIS π
#include <tcl.h>
int
Tcl_DoOneEvent(flags)
π¦ ARGUMENTS π¦
int flags(in) β bestie this is normally just zero, like, no thoughts head empty. But you can pass an OR-ed combo of any of these flag bits:TCL_WINDOW_EVENTS,TCL_FILE_EVENTS,TCL_TIMER_EVENTS,TCL_IDLE_EVENTS,TCL_ALL_EVENTS, orTCL_DONT_WAIT. Mix and match, she's flexible πβοΈ
β¨ DESCRIPTION β¨
This procedure is the entry point to Tcl's event loop, like the front door of the whole party πͺπ. She's the one responsible for waiting for events and dispatching the event handlers that got created with procedures such as Tk_CreateEventHandler, Tcl_CreateFileHandler, Tcl_CreateTimerHandler, and Tcl_DoWhenIdle.
Here's the run of show, in order, no skips:
Tcl_DoOneEventpeeks to see if events are already sitting on the Tcl event queue. If yes? She calls the handler(s) for the first (oldest) event, removes it from the queue, and returns. periodt βοΈ- If there are no events ready to be handled, she checks for new events from all possible sources. If she finds any, she puts all of them on Tcl's event queue, calls handlers for the first event on the queue, and returns.
- If no events are found, she checks for
Tcl_DoWhenIdlecallbacks. If any are found, she invokes all of them and returns π―βοΈ - Finally, if no events or idle callbacks turned up,
Tcl_DoOneEventsleeps until an event occurs. Then she adds any new events to the Tcl event queue, calls handlers for the first event, and returns π΄β‘οΈπ₯
The normal return value is 1, which signifies that some event was processed (scroll down for the other alternatives, bestie).
If the flags argument is non-zero, it restricts the kinds of events that Tcl_DoOneEvent will process. Flags may be an OR-ed combination of any of these bits:
TCL_WINDOW_EVENTSβ process window system events πͺTCL_FILE_EVENTSβ process file events πTCL_TIMER_EVENTSβ process timer events β°TCL_IDLE_EVENTSβ process idle callbacks πTCL_ALL_EVENTSβ process all kinds of events. This is equivalent to OR-ing together all of the above flags, or just specifying none of them at all. Same energy, different outfit πTCL_DONT_WAITβ do NOT sleep. Process only the events that are ready at the time of the call πβοΈ
If any of the flags TCL_WINDOW_EVENTS, TCL_FILE_EVENTS, TCL_TIMER_EVENTS, or TCL_IDLE_EVENTS is set, then the only events considered are those for which flags are set. Setting none of these flags is equivalent to the value TCL_ALL_EVENTS, which causes all event types to be processed. And if an application has defined additional event sources with Tcl_CreateEventSource, then additional flag values may also be valid, depending on those event sources π
The TCL_DONT_WAIT flag makes Tcl_DoOneEvent not put the process to sleep: she'll check for events, but if none are found she returns immediately with a return value of 0 to indicate that no work was done π
Tcl_DoOneEventwill also return0without doing anything if the only alternative is to block forever. This can happen, for example, ifflagsisTCL_IDLE_EVENTSand there are noTcl_DoWhenIdlecallbacks pending, or if no event handlers or timer handlers exist. She is not about to stand there waiting on nothing, bestie π«β³
Tcl_DoOneEvent may be invoked recursively. For example, it is possible to invoke Tcl_DoOneEvent recursively from a handler that was called by Tcl_DoOneEvent. This sort of operation is useful in some modal situations β like when a notification dialog has been popped up and an application wishes to wait for the user to click a button in the dialog before doing anything else. main character energy, honestly π«Ά
π KEYWORDS π
callback, event, handler, idle, timer
and that's the whole page, babe π this one's straight outta the Tcl 7.5 era, dated 7.5, and it lives in the Tcl_DoOneEvent(3) section of the Tcl library manual β go forth and dispatch your events, you absolute icon πβ¨
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- Copyright (c) 1990-1992 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms