focus
option
]
window
]Manage the Tk input focus. At any given time, one window on each display is given the focus so that key press and key release events for the display are sent to that window. Tk remembers the last window in each top-level window to receive the focus. When the window manager gives the focus to a top-level window, Tk automatically redirects it to the remembered window.
Focus within a Tk top-level window uses an explicit focus model by default (i.e., moving the mouse within a top-level window does not change the focus). The model can be changed to implicit (focus changes to a window whenever the mouse enters it) by calling the tk_focusFollowsMouse procedure.
The Tcl procedures tk_focusNext and
tk_focusPrev implement a focus order
among the windows of a top-level window. They return the next
and previous windows after window
in the focus order that accepts the focus (see the
-takefocus widget configuration option).
The focus order is determined by the structure of the window
hierarchy and by the stacking order of the windows among
siblings.
The focus command can take the following forms:
window
]Return the pathname of the focus window on the
display containing window
. If
not given, window
defaults to
the root window.
window
If the application currently has the input focus
for window
’s display, the
focus is given to window
.
Otherwise, window
is made the
remembered focus window for its top-level window.
window
Set the focus of
window
’s display to
window
even if the
application doesn’t currently have the input focus for
the display.
window
Return the pathname of the window to most recently
own the input focus among all windows in the same
top-level window as window
(i.e., the remembered window). If no window currently
present in that top level has ever had the input focus,
the name of the top-level window is returned.