Tabbing between views is a common way for the user to move quickly between a set of text fields in a window, enabling the fast entry of data using only the keyboard. When the user presses the tab key, focus moves from control to control, usually in a circular pattern. For Carbon developers, the code to manage this change in keyboard focus must be written manually in Xcode. Cocoa, however, builds in automatic support for tabbing into the NSView class.
When the user presses the tab key, Cocoa uses the nextKeyView outlet of the view that currently has the focus to determine where the focus should move to next. To set up the tab order for a particular window, all you have to do is configure this outlet for each view. It is recommended that you configure all of your views at once, moving from one view to the next to ensure that the chain is really circular and comes back to the right starting point.
To specify the view that should receive the focus when the window is first shown, connect the initialFirstResponder outlet of the window to the desired view.
Last updated: 2007-10-31