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

  1. '\"
  2. '\" Copyright (c) 19922 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/CrtGenHdlr.3,v 1.3 93/04/01 09:41:14 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS Tk_CreateGenericHandler tkc
  25. .BS
  26. .SH NAME
  27. Tk_CreateGenericHandler, Tk_DeleteGenericHandler \- associate procedure callback with all X events
  28. .SH SYNOPSIS
  29. .nf
  30. \fB#include <tk.h>\fR
  31. .sp
  32. \fBTk_CreateGenericHandler\fR(\fIproc, clientData\fR)
  33. .sp
  34. \fBTk_DeleteGenericHandler\fR(\fIproc, clientData\fR)
  35. .SH ARGUMENTS
  36. .AS "Tk_GenericProc" clientData
  37. .AP Tk_GenericProc *proc in
  38. Procedure to invoke whenever any X event occurs on any display.
  39. .AP ClientData clientData in
  40. Arbitrary one-word value to pass to \fIproc\fR.
  41. .BE
  42.  
  43. .SH DESCRIPTION
  44. .PP
  45. \fBTk_CreateGenericHandler\fR arranges for \fIproc\fR to be
  46. invoked in the future whenever any X event occurs.  This mechanism is
  47. \fInot\fR intended for dispatching X events on windows managed by Tk
  48. (you should use \fBTk_CreateEventHandler\fR for this purpose).
  49. \fBTk_CreateGenericHandler\fR is intended for other purposes, such
  50. as tracing X events, monitoring events on windows not owned by Tk,
  51. accessing X-related libraries that were not originally designed for
  52. use with Tk, and so on.
  53. .PP
  54. The callback to \fIproc\fR will be made by \fBTk_HandleEvent\fR;
  55. this mechanism only works in programs that dispatch events
  56. through \fBTk_HandleEvent\fR (or through other Tk procedures that
  57. call \fBTk_HandleEvent\fR, such as \fBTk_DoOneEvent\fR or
  58. \fBTk_MainLoop\fR).
  59. .PP
  60. \fIProc\fP should have arguments and result that match the
  61. type \fBTk_GenericProc\fR:
  62. .nf
  63. .RS
  64. typedef int Tk_GenericProc(
  65. .RS
  66. ClientData \fIclientData\fR,
  67. XEvent *\fIeventPtr\fR);
  68. .RE
  69. .RE
  70. .fi
  71. The \fIclientData\fP parameter to \fIproc\fR is a copy of the \fIclientData\fP
  72. argument given to \fBTk_CreateGenericHandler\fR when the callback
  73. was created.  Typically, \fIclientData\fR points to a data
  74. structure containing application-specific information about
  75. how to handle events.
  76. \fIEventPtr\fR is a pointer to the X event.
  77. .PP
  78. Whenever an X event is processed by \fBTk_HandleEvent\fR, \fIproc\fR
  79. is called.  The return value from \fIproc\fR is normally 0.
  80. A non-zero return value indicates that the event is not to be handled
  81. further; that is, \fIproc\fR has done all processing that is to be
  82. allowed for the event.
  83. .PP
  84. If there are multiple generic event handlers, each one is called
  85. for each event, in the order in which they were established.
  86. .PP
  87. \fBTk_DeleteGenericHandler\fR may be called to delete a
  88. previously-created generic event handler:  it deletes each handler
  89. it finds that matches the \fIproc\fR and \fIclientData\fR arguments.  If
  90. no such handler exists, then \fBTk_DeleteGenericHandler\fR returns
  91. without doing anything.  Although Tk supports it, it's probably
  92. a bad idea to have more than one callback with the same
  93. \fIproc\fR and \fIclientData\fR arguments.
  94. .PP
  95. Establishing a generic event handler does nothing to ensure that the
  96. process will actually receive the X events that the handler wants to
  97. process.
  98. For example, it is the caller's responsibility to invoke
  99. \fBXSelectInput\fR to select the desired events, if that is necessary.
  100. .SH KEYWORDS
  101. bind, callback, event, handler
  102.