1grab(3)               User Contributed Perl Documentation              grab(3)
2
3
4

NAME

6       Tk::grab - Confine pointer and keyboard events to a window sub-tree
7

SYNOPSIS

9       $widget->grab
10
11       $widget->grabOption
12

DESCRIPTION

14       This set of methods implement simple pointer and keyboard grabs for Tk.
15       Tk's grabs are different than the grabs described in the Xlib
16       documentation.  When a grab is set for a particular window, Tk
17       restricts all pointer events to the grab window and its descendants in
18       Tk's window hierarchy.  Whenever the pointer is within the grab
19       window's subtree, the pointer will behave exactly the same as if there
20       had been no grab at all and all events will be reported in the normal
21       fashion.  When the pointer is outside $widget's tree, button presses
22       and releases and mouse motion events are reported to $widget, and
23       window entry and window exit events are ignored.  The grab subtree
24       ``owns'' the pointer: windows outside the grab subtree will be visible
25       on the screen but they will be insensitive until the grab is released.
26       The tree of windows underneath the grab window can include top-level
27       windows, in which case all of those top-level windows and their
28       descendants will continue to receive mouse events during the grab.
29
30       Two forms of grabs are possible:  local and global.  A local grab
31       affects only the grabbing application:  events will be reported to
32       other applications as if the grab had never occurred.  Grabs are local
33       by default.  A global grab locks out all applications on the screen, so
34       that only the given subtree of the grabbing application will be
35       sensitive to pointer events (mouse button presses, mouse button
36       releases, pointer motions, window entries, and window exits).  During
37       global grabs the window manager will not receive pointer events either.
38
39       During local grabs, keyboard events (key presses and key releases) are
40       delivered as usual:  the window manager controls which application
41       receives keyboard events, and if they are sent to any window in the
42       grabbing application then they are redirected to the focus window.
43       During a global grab Tk grabs the keyboard so that all keyboard events
44       are always sent to the grabbing application.  The focus method is still
45       used to determine which window in the application receives the keyboard
46       events.  The keyboard grab is released when the grab is released.
47
48       Grabs apply to particular displays.  If an application has windows on
49       multiple displays then it can establish a separate grab on each
50       display.  The grab on a particular display affects only the windows on
51       that display.  It is possible for different applications on a single
52       display to have simultaneous local grabs, but only one application can
53       have a global grab on a given display at once.
54
55       The grab methods take any of the following forms:
56
57       $widget->grabCurrent
58           Returns the current grab window in this application for $widget's
59           display, or an empty string if there is no such window.
60
61       $widget->grabs
62           Returns a list whose elements are all of the windows grabbed by
63           this application for all displays, or an empty string if the
64           application has no grabs.
65
66           Not implemented yet!
67
68       $widget->grabRelease
69           Releases the grab on $widget if there is one, otherwise does
70           nothing.  Returns an empty string.
71
72       $widget->grab
73           Sets a local grab on $widget.  If a grab was already in effect for
74           this application on $widget's display then it is automatically
75           released.  If there is already a local grab on $widget, then the
76           command does nothing.  Returns an empty string.
77
78       $widget->grabGlobal
79           Sets a global grab on $widget.  If a grab was already in effect for
80           this application on $widget's display then it is automatically
81           released.  If there is already a global grab on $widget, then the
82           command does nothing.  Returns an empty string.
83
84       $widget->grabStatus
85           Returns none if no grab is currently set on $widget, local if a
86           local grab is set on $widget, and global if a global grab is set.
87

BUGS

89       It took an incredibly complex and gross implementation to produce the
90       simple grab effect described above.  Given the current implementation,
91       it isn't safe for applications to use the Xlib grab facilities at all
92       except through the Tk grab procedures.  If applications try to
93       manipulate X's grab mechanisms directly, things will probably break.
94
95       If a single process is managing several different Tk applications, only
96       one of those applications can have a local grab for a given display at
97       any given time.  If the applications are in different processes, this
98       restriction doesn't exist.
99

KEYWORDS

101       grab, keyboard events, pointer events, window
102
103
104
105perl v5.32.1                      2021-01-27                           grab(3)
Impressum