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

  1. '\"
  2. '\" Copyright (c) 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/grab.n,v 1.7 93/04/01 09:52:41 ouster Exp $ SPRITE (Berkeley)
  22. '/" 
  23. .so man.macros
  24. .HS grab tk
  25. .BS
  26. '\" Note:  do not modify the .SH NAME line immediately below!
  27. .SH NAME
  28. grab \- Confine pointer and keyboard events to a window sub-tree
  29. .SH SYNOPSIS
  30. \fBgrab \fR?\fB\-global\fR? \fIwindow\fR
  31. .br
  32. .VS
  33. \fBgrab \fIoption \fR?arg arg \fR...?
  34. .VE
  35. .BE
  36.  
  37. .SH DESCRIPTION
  38. .PP
  39. This command implements simple pointer and keyboard grabs for Tk.
  40. Tk's grabs are different than the grabs
  41. described in the Xlib documentation.
  42. When a grab is set for a particular window, Tk restricts all pointer
  43. events to the grab window and its descendants in Tk's window hierarchy.
  44. Whenever the pointer is within the grab window's subtree, the pointer
  45. will behave exactly the same as if there had been no grab at all
  46. and all events will be reported in the normal fashion.
  47. When the pointer is outside \fIwindow\fR's tree, button presses and
  48. releases and
  49. mouse motion events are reported to \fIwindow\fR, and window entry
  50. and window exit events are ignored.
  51. The grab subtree ``owns'' the pointer:
  52. windows outside the grab subtree will be visible on the screen
  53. but they will be insensitive until the grab is released.
  54. The tree of windows underneath the grab window can include top-level
  55. windows, in which case all of those top-level windows
  56. and their descendants will continue to receive mouse events
  57. during the grab.
  58. .PP
  59. Two forms of grabs are possible:  local and global.
  60. A local grab affects only the grabbing application:  events will
  61. be reported to other applications as if the grab had never occurred.
  62. Grabs are local by default.
  63. A global grab locks out all applications on the screen,
  64. so that only the given subtree of the grabbing application will be
  65. sensitive to pointer events (mouse button presses, mouse button releases,
  66. pointer motions, window entries, and window exits).
  67. During global grabs the window manager will not receive pointer
  68. events either.
  69. .PP
  70. During local grabs, keyboard events (key presses and key releases)
  71. are delivered as usual:  the window
  72. manager controls which application receives keyboard events, and
  73. if they are sent to any window in the grabbing application then they are
  74. redirected to the focus window.
  75. During a global grab Tk grabs the keyboard so that all keyboard events
  76. are always sent to the grabbing application.
  77. The \fBfocus\fR command is still used to determine which window in the
  78. application receives the keyboard events.
  79. The keyboard grab is released when the grab is released.
  80. .PP
  81. Grabs apply to particular displays.  If an application has windows
  82. on multiple displays then it can establish a separate grab on each
  83. display.
  84. The grab on a particular display affects only the windows on
  85. that display.
  86. It is possible for different applications on a single display to have
  87. simultaneous local grabs, but only one application can have a global
  88. grab on a given display at once.
  89. .PP
  90. The \fBgrab\fR command can take any of the following forms:
  91. .TP
  92. \fBgrab \fR?\fB\-global\fR? \fIwindow\fR
  93. .VS
  94. Same as \fBgrab set\fR, described below.
  95. .TP
  96. \fBgrab current \fR?\fIwindow\fR?
  97. If \fIwindow\fR is specified, returns the name of the current grab
  98. window in this application for \fIwindow\fR's display, or an empty
  99. string if there is no such window.
  100. If \fIwindow\fR is omitted, the command returns a list whose elements
  101. are all of the windows grabbed by this application for all displays,
  102. or an empty string if the application has no grabs.
  103. .TP
  104. \fBgrab release \fIwindow\fR
  105. Releases the grab on \fIwindow\fR if there is one, otherwise does
  106. nothing.  Returns an empty string.
  107. .TP
  108. \fBgrab set \fR?\fB\-global\fR? \fIwindow\fR
  109. Sets a grab on \fIwindow\fR.  If \fB\-global\fR is specified then the
  110. grab is global, otherwise it is local.
  111. If a grab was already in effect for this application on
  112. \fIwindow\fR's display then it is automatically released.
  113. If there is already a grab on \fIwindow\fR and it has the same
  114. global/local form as the requested grab, then the command
  115. does nothing.  Returns an empty string.
  116. .TP
  117. \fBgrab status \fIwindow\fR
  118. Returns \fBnone\fR if no grab is currently set on \fIwindow\fR,
  119. \fBlocal\fR if a local grab is set on \fIwindow\fR, and
  120. \fBglobal\fR if a global grab is set.
  121. .VE
  122.  
  123. .SH BUGS
  124. .PP
  125. It took an incredibly complex and gross implementation to produce
  126. the simple grab effect described above.
  127. Given the current implementation, it isn't safe for applications
  128. to use the Xlib grab facilities at all except through the Tk grab
  129. procedures.
  130. If applications try to manipulate X's grab mechanisms directly,
  131. things will probably break.
  132. .PP
  133. .VS
  134. If a single process is managing several different Tk applications,
  135. only one of those applications can have a local grab for a given
  136. display at any given time.  If the applications are in different
  137. processes, this restriction doesn't exist.
  138. .VE
  139.  
  140. .SH KEYWORDS
  141. grab, keyboard events, pointer events, window
  142.