Important: The information in this document is obsolete and should not be used for new development.
PATH![]() |
![]() ![]() |
A control with keyboard focus receives keyboard events. The Dialog Manager tests to see which control has keyboard focus when a keyboard event is processed and sends the event to that control. If no control has keyboard focus, the keyboard event is discarded. Currently, the list box, clock, and editable text controls are the only standard system controls that support keyboard focus. A control retains keyboard focus if it is hidden or deactivated.
A focus ring is drawn around the control with keyboard focus. When creating your own controls, allow space for the focus ring. For more details on designing with focus rings, see Mac OS 8 Human Interface Guidelines .
Keyboard focus is only available if an embedding hierarchy has been established in the focusable control's window. The default focusing order is based on the order in which controls are added to the window. For more details on embedding hierarchies, see Embedding Controls .
The following Control Manager functions for handling keyboard focus are new with Appearance Manager 1.0:
SetKeyboardFocus
sets the current keyboard focus to a specified control part for a window. New with Appearance Manager 1.0.GetKeyboardFocus
obtains a handle to the control with the current keyboard focus for a specified window. New with Appearance Manager 1.0.AdvanceKeyboardFocus
advances the keyboard focus to the next focusable control in a window. New with Appearance Manager 1.0.ReverseKeyboardFocus
returns keyboard focus to the prior focusable control in a window. New with Appearance Manager 1.0.ClearKeyboardFocus
removes the keyboard focus for the currently focused control in a window. New with Appearance Manager 1.0.Sets the current keyboard focus to a specified control part for a window.
pascal OSErr SetKeyboardFocus (
WindowPtr inWindow,
ControlHandle inControl,
ControlFocusPart inPart);
inWindow
inControl
inPart
kControlFocusNoPart
. See Handling Keyboard Focus
.
The SetKeyboardFocus
function sets the keyboard focus to a specified control part. The control to receive keyboard focus can be deactivated or invisible. This permits you to set the focus for an item in a dialog box before the dialog box is displayed.
Obtains a handle to the control with the current keyboard focus for a specified window.
pascal OSErr GetKeyboardFocus (
WindowPtr inWindow,
ControlHandle* outControl);
inWindow
outControl
ControlHandle
value. On return, the ControlHandle
value is set to a handle to the control that currently has keyboard focus. Produces nil
if no control has focus.
The GetKeyboardFocus
function returns the handle of the control with current keyboard focus within a specified window.
Advances the keyboard focus to the next focusable control in a window.
pascal OSErr AdvanceKeyboardFocus (WindowPtr inWindow);
inWindow
The AdvanceKeyboardFocus
function skips over deactivated and hidden controls until it finds the next focusable control in the window. If it does not find a focusable item, it simply returns.
When AdvanceKeyboardFocus
is called, the Control Manager calls your control definition function and passes kControlMsgFocus
in its message
parameter and kControlFocusNextPart
in its param
parameter. In response to this message, your control definition function should change keyboard focus to its next part, the entire control, or remove keyboard focus from the control, depending upon the circumstances. see Handling Keyboard Focus
for a discussion of possible responses to this message.
Returns keyboard focus to the prior focusable control in a window.
pascal OSErr ReverseKeyboardFocus (WindowPtr inWindow);
inWindow
The ReverseKeyboardFocus
function reverses the progression of keyboard focus, skipping over deactivated and hidden controls until it finds the previous control to receive keyboard focus in the window.
When ReverseKeyboardFocus
is called, the Control Manager calls your control definition function and passes kControlMsgFocus
in its message
parameter and kControlFocusPrevPart
in its param
parameter. In response to this message, your control definition function should change keyboard focus to its previous part, the entire control, or remove keyboard focus from the control, depending upon the circumstances. see Handling Keyboard Focus
for a discussion of possible responses to this message.
Removes the keyboard focus for the currently focused control in a window.
pascal OSErr ClearKeyboardFocus (WindowPtr inWindow);
inWindow
When the ClearKeyboardFocus
function is called, the Control Manager calls your control definition function and passes kControlMsgFocus
in its message
parameter and kControlFocusNoPart
in its param
parameter. see Handling Keyboard Focus
for a discussion of possible responses to this message.