Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Tk / focus.pod
CommitLineData
86530b38
AT
1# Copyright (c) 1990-1994 The Regents of the University of California.
2# Copyright (c) 1994-1996 Sun Microsystems, Inc.
3# See the file "license.terms" for information on usage and redistribution
4# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
5#
6#
7
8=head1 NAME
9
10focus - Manage the input focus
11
12=for category User Interaction
13
14=head1 SYNOPSIS
15
16S< >I<$widget>-E<gt>B<focus>
17
18S< >I<$widget>-E<gt>B<focus>I<Option>
19
20S< >I<$widget>-E<gt>B<focusNext>
21
22S< >I<$widget>-E<gt>B<focusPrev>
23
24S< >I<$widget>-E<gt>B<focusFollowsMouse>
25
26=head1 DESCRIPTION
27
28The B<focus> methods are used to manage the Tk input focus.
29At any given time, one window on each display is designated as
30the I<focus window>; any key press or key release events for the
31display are sent to that window.
32It is normally up to the window manager to redirect the focus among the
33top-level windows of a display. For example, some window managers
34automatically set the input focus to a top-level window whenever
35the mouse enters it; others redirect the input focus only when
36the user clicks on a window.
37Usually the window manager will set the focus
38only to top-level windows, leaving it up to the application to
39redirect the focus among the children of the top-level.
40
41Tk remembers one focus window for each top-level (the most recent
42descendant of that top-level to receive the focus); when the window
43manager gives the focus
44to a top-level, Tk automatically redirects it to the remembered
45window. Within a top-level Tk uses an I<explicit> focus model
46by default. Moving the mouse within a top-level does not normally
47change the focus; the focus changes only when a widget
48decides explicitly to claim the focus (e.g., because of a button
49click), or when the user types a key such as Tab that moves the
50focus.
51
52The method B<focusFollowsMouse> may be invoked to
53create an I<implicit> focus model: it reconfigures Tk so that
54the focus is set to a window whenever the mouse enters it.
55The methods B<focusNext> and B<focusPrev>
56implement a focus order among the windows of a top-level; they
57are used in the default bindings for Tab and Shift-Tab, among other
58things.
59
60The B<focus> methods can take any of the following forms:
61
62=over 4
63
64=item I<$widget>-E<gt>B<focusCurrent>
65
66Returns the focus window on the display containing
67the I<$widget>, or an empty string if no window in
68this application has the focus on that display.
69
70=item I<$widget>-E<gt>B<focus>
71
72If the application currently has the input focus on I<$widget>'s
73display, this command resets the input focus for I<$widget>'s display
74to I<$widget> and returns an empty string.
75If the application doesn't currently have the input focus on
76I<$widget>'s display, I<$widget> will be remembered as the focus
77for its top-level; the next time the focus arrives at the top-level,
78Tk will redirect it to I<$widget>.
79
80=item I<$widget>-E<gt>B<focusForce>
81
82Sets the focus of I<$widget>'s display to I<$widget>, even if
83the application doesn't currently have the input focus for the display.
84This command should be used sparingly, if at all.
85In normal usage, an application should not claim the focus for
86itself; instead, it should wait for the window manager to give it
87the focus.
88
89=item I<$widget>-E<gt>B<focusLast>
90
91Returns the name of the most recent window to have the input focus
92among all the windows in the same top-level as I<$widget>.
93If no window in that top-level has ever had the input focus, or
94if the most recent focus window has been deleted, then
95the top-level is returned. The return value is the window that
96will receive the input focus the next time the window manager gives
97the focus to the top-level.
98
99=item I<$widget>-E<gt>B<focusNext>
100
101=item I<$widget>-E<gt>B<focusPrev>
102
103B<focusNext> is a utility method used for keyboard traversal, but can be
104useful in other contexts.
105It sets the focus to the ``next'' window after I<$widget> in focus order.
106The focus order is determined by
107the stacking order of windows and the structure of the window hierarchy.
108Among siblings, the focus order is the same as the stacking order, with the
109lowest window being first.
110If a window has children, the window is visited first, followed by
111its children (recursively), followed by its next sibling.
112Top-level windows other than I<$widget> are skipped, so that
113B<focusNext> never returns a window in a different top-level
114from I<$widget>.
115
116After computing the next window, B<focusNext> examines the
117window's B<-takefocus> option to see whether it should be skipped.
118If so, B<focusNext> continues on to the next window in the focus
119order, until it eventually finds a window that will accept the focus
120or returns back to I<$widget>.
121
122B<focusPrev> is similar to B<focusNext> except that it
123sets the focus to the window just before I<$widget> in the focus order.
124
125=item I<$widget>-E<gt>B<focusFollowsMouse>
126
127B<focusFollowsMouse> changes the focus model for the application
128to an implicit one where the window under the mouse gets the focus.
129After this procedure is called, whenever the mouse enters a window
130Tk will automatically give it the input focus.
131The B<focus> command may be used to move the focus to a window
132other than the one under the mouse, but as soon as the mouse moves
133into a new window the focus will jump to that window.
134Note: at present there is no built-in support for returning the
135application to an explicit focus model; to do this you'll have
136to write a script that deletes the bindings created by
137B<focusFollowsMouse>.
138
139=back
140
141=head1 QUIRKS
142
143When an internal window receives the input focus, Tk doesn't actually
144set the X focus to that window; as far as X is concerned, the focus
145will stay on the top-level window containing the window with the focus.
146However, Tk generates FocusIn and FocusOut events just as if the X
147focus were on the internal window. This approach gets around a
148number of problems that would occur if the X focus were actually moved;
149the fact that the X focus is on the top-level is invisible unless
150you use C code to query the X server directly.
151
152=head1 CAVEATS
153
154Note that for the B<Canvas> widget, the call to B<focus> has to be
155fully qualified. This is because there is already a focus method for
156the B<Canvas> widget, which sets the focus on individual canvas tags.
157
158S< >I<$canvas>-E<gt>B<Tk::focus>
159
160
161=head1 KEYWORDS
162
163events, focus, keyboard, top-level, window manager
164
165=cut
166