home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / tcl / tk3.3b1 / doc / DoOneEvent.3 < prev    next >
Encoding:
Text File  |  1993-04-01  |  5.5 KB  |  144 lines

  1. '\"
  2. '\" Copyright (c) 1990-1992 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/wish/man/RCS/DoOneEvent.3,v 1.8 93/04/01 09:41:17 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS Tk_DoOneEvent tkc
  25. .BS
  26. .SH NAME
  27. Tk_DoOneEvent, Tk_MainLoop, Tk_HandleEvent \- wait for events and
  28. invoke event handlers
  29. .SH SYNOPSIS
  30. .nf
  31. \fB#include <tk.h>\fR
  32. .sp
  33. int
  34. .VS
  35. \fBTk_DoOneEvent\fR(\fIflags\fR)
  36. .VE
  37. .sp
  38. \fBTk_MainLoop\fR()
  39. .sp
  40. \fBTk_HandleEvent\fR(\fIeventPtr\fR)
  41. .SH ARGUMENTS
  42. .AS XEvent *eventPtr
  43. .AP int flags in
  44. .VS
  45. This parameter is normally zero.  It may be an OR-ed combination
  46. of any of the following flag bits:  TK_X_EVENTS, TK_FILE_EVENTS,
  47. TK_TIMER_EVENTS, TK_IDLE_EVENTS, TK_ALL_EVENTS, or TK_DONT_WAIT.
  48. .VE
  49. .AP XEvent *eventPtr in
  50. Pointer to X event to dispatch to relevant handler(s).
  51. .BE
  52.  
  53. .SH DESCRIPTION
  54. .PP
  55. These three procedures are responsible for waiting for events
  56. and dispatching to event handlers created with the procedures
  57. \fBTk_CreateEventHandler\fR, \fBTk_CreateFileHandler\fR,
  58. \fBTk_CreateTimerHandler\fR, and \fBTk_DoWhenIdle\fR.
  59. \fBTk_DoOneEvent\fR is the key procedure.  It waits for a single
  60. event of any sort to occur, invokes the handler(s) for that
  61. event, and then returns.  \fBTk_DoOneEvent\fR first checks
  62. for X events and file-related events;  if one is found then
  63. it calls the handler(s) for the event and returns.  If there
  64. are no X or file events pending, then \fBTk_DoOneEvent\fR
  65. checks to see if timer callbacks are ready;  if so, it
  66. makes a single callback and returns.  If no timer callbacks
  67. are ready, \fBTk_DoOneEvent\fR checks for \fBTk_DoWhenIdle\fR
  68. callbacks;  if any are found, it invokes all of them and returns.
  69. Finally, if events or work have been found found, \fBTk_DoOneEvent\fR
  70. sleeps until a timer, file, or X event occurs;  then it processes
  71. the first event found (in the order given above) and returns.
  72. The normal return value is 1 to signify that some event or callback
  73. was processed.
  74. .PP
  75. If the \fIflags\fR argument to \fBTk_DoOneEvent\fR is non-zero then
  76. .VS
  77. it restricts the kinds of events that will be processed by
  78. \fBTk_DoOneEvent\fR.
  79. \fIFlags\fR may be an OR-ed combination of any of the following bits:
  80. .TP 24
  81. \fBTK_X_EVENTS\fR \-
  82. Process X events.
  83. .TP 24
  84. \fBTK_FILE_EVENTS\fR \-
  85. Process file events.
  86. .TP 24
  87. \fBTK_TIMER_EVENTS\fR \-
  88. Process timer events.
  89. .TP 24
  90. \fBTK_IDLE_EVENTS\fR \-
  91. Process \fBTk_DoWhenIdle\fR callbacks.
  92. .TP 24
  93. \fBTK_ALL_EVENTS\fR \-
  94. Process all kinds of events:  equivalent to OR-ing together all of the
  95. above flags or specifying none of them.
  96. .TP 24
  97. \fBTK_DONT_WAIT\fR \-
  98. Don't sleep:  process only events that are ready at the time of the
  99. call.
  100. .LP
  101. If any of the flags \fBTK_X_EVENTS\fR, \fBTK_FILE_EVENTS\fR,
  102. \fBTK_TIMER_EVENTS\fR, or \fBTK_IDLE_EVENTS\fR is set, then the only
  103. events that will be considered are those for which flags are set.
  104. Setting none of these flags is equivalent to the value
  105. \fBTK_ALL_EVENTS\fR, which causes all event types to be processed.
  106. .PP
  107. The \fBTK_DONT_WAIT\fR flag causes \fBTk_DoWhenIdle\fR not to put
  108. the process to sleep:  it will check for events but if none are found
  109. then it returns immediately with a return value of 0 to indicate
  110. that no work was done.
  111. \fBTk_DoOneEvent\fR will also return 0 without doing anything if
  112. \fIflags\fR is \fBTK_IDLE_EVENTS\fR and there are no
  113. \fBTk_DoWhenIdle\fR callbacks pending.
  114. .VE
  115. .PP
  116. \fBTk_MainLoop\fR is a procedure that loops repeatedly
  117. calling \fBTk_DoOneEvent\fR.  It returns only when there
  118. are no applications left in this process (i.e. no main windows
  119. exist anymore).  Most X applications will
  120. call \fBTk_MainLoop\fR after initialization;  the main
  121. execution of the application will consist entirely of
  122. callbacks invoked by \fBTk_DoOneEvent\fR.
  123. .PP
  124. \fBTk_HandleEvent\fR is a lower-level procedure invoked
  125. by \fBTk_DoOneEvent\fR.  It makes callbacks to any event
  126. handlers (created by calls to \fBTk_CreateEventHandler\fR)
  127. that match \fIeventPtr\fR and then returns.  In some cases
  128. it may be useful for an application to read events directly
  129. from X and dispatch them by calling \fBTk_HandleEvent\fR,
  130. without going through the additional mechanism provided
  131. by \fBTk_DoOneEvent\fR.
  132. .PP
  133. These procedures may be invoked recursively.  For example,
  134. it is possible to invoke \fBTk_DoOneEvent\fR recursively
  135. from a handler called by \fBTk_DoOneEvent\fR.  This sort
  136. of operation is useful in some modal situations, such
  137. as when a
  138. notifier has been popped up and an application wishes to
  139. wait for the user to click a button in the notifier before
  140. doing anything else.
  141.  
  142. .SH KEYWORDS
  143. callback, event, handler, idle, timer
  144.