NSTabView keyboard navigation (was Re: TabView textField Ordering incorrect)
NSTabView keyboard navigation (was Re: TabView textField Ordering incorrect)
- Subject: NSTabView keyboard navigation (was Re: TabView textField Ordering incorrect)
- From: Chuck Pisula <email@hidden>
- Date: Thu, 30 Aug 2001 11:03:32 -0700
Folks,
I've seen a lot of emails posted to various developer list saying
keyboard loops don't work in NSTabViews in Mac OS 10.0.X. This is
absolutely correct. I don't want to comment on what doesn't work
because .... it basically doesn't work well at all.
The good news is that this problem is being addressed in 10.1. I want
to comment on how I would expect tab ordering to work in an
NSTabView. This should help you get your tab view to be a proper part
of your windows keyboard loop. Because I think this will be generally
useful information, I've decided to cross-post this message.
Hope this information helps,
-chuck
Some notes about keyboard navigation and NSTabView
Using the tab key, users can place keyboard focus on an NSTabView and
switch between tab items by pressing the arrow keys. With focus on the
tab view itself, hitting tab will take the user to the selected item's
initialFirstResponder. Continuing to tab will take users through the
keyloop you have defined, eventually leading a user out of the NSTabView
(usually the view connected as the tab view's nextKeyView in IB).
There are a couple of details that should be mentioned:
- The initially provided nextKeyView of a NSTabView (usually done in IB)
is remembered as the "original next key view". The last key view in a
NSTabViewItem's loop will be given the "original next key view" as its
next key view. If there is no original next key view, the last key
view's will be wired to the tab view itself.
- Each NSTabViewItem should provide an initialFirstResponder and a valid
keyboard loop. If you do not prvide one, it is assumed you have, in
fact, not provided any keyboard loop. Therefore, a keyboard loop will
automatically be created.
- The keyboard loop you provide should not contain cycles. If found, the
cycle may be broken, so that tabbing past the last key view will take
users out of the tab view. The location the cycle is broken will be
considered the item's last key view.
- The keyboard loop you define should not lead outside of a
NSTabViewItems view. If this is detected, the link causing keyboard
focus to leave the view may be broken. This location will be considered
the item's last key view.
Summary: Each NSTabView should have an original next key view. Each
NSTabView items should be given an initialFirstResponder, and a valid
keyboard loop. Typically using the tab key will take user to the tab,
through the selected items keyboard loop, and then out the other side.
General notes & tips about keyboard navigation
- Your keyboard loop should contain every control you want to be
accessible via the keyboard. Typically you should just place every view
somewhere in the keyboard loop. If the view returns NO from
acceptsFirstResponder it won't be given keyboard focus and will be
skipped over during tabbing.
- NSWindow and NSTabViewItem each have an 'initialFirstResponder'
instance variable. If this variable is not set, it is assumed that you
have do not have a valid keyboard loop, so one will be computed for you
by following the views in a geometric order.
- When adding and removing views from a window, take care to properly
"splice" the view in and out of the keyboard loop. Many developers
forget to do this, and end up with views in the keyboard loop that
aren't visible.
- In 10.0.X, your best bet for NSTabViews is to make sure each items
initialFirstResponder is connected, and the entire keyboard loop is
specified. Further, make sure the NSTabView's nextKeyView is connected
to something that makes sense in IB. As I said earlier, NSTabViews
keyboard loops in 10.0.X is buggy, so your mileage may vary.
On Saturday, August 25, 2001, at 02:36 AM, Bill Cheeseman wrote:
>
on 8/24/01 10:29 PM, Richard Whittaker at email@hidden wrote:
>
>
> I am having a little problem with a NSTabView. The tabView has two tabs
>
> billTo and shipTo: . the problem is at the order of going through each
>
> tab's textfield is not
>
> correct.
>
>
It seems clear to me that tabbing order in tab view items is broken in
>
IB.
>
I've had similar problems, where tabbing out of one text field simply
>
doesn't work, while tabbing out of all the others does. When I
>
disconnect a
>
couple of connections and then reconnect them the same way, the problem
>
sometimes goes away, but then it returns the next time I make any
>
change to
>
the nib file.
>
>
Upgrading to a certain OS version that we can't yet talk about appears
>
to
>
cure the problem.
>
>
> Also is it possible to tab through all the tabs
>
> ie I am that last billTo textField I hit the tab key which bring me to
>
> the first textField in the shipTo Tab?????
>
>
You probably realize that this isn't officially sanctioned Human
>
Interface
>
behavior. To do it, I imagine you would have to intercept the tab key
>
(this
>
would perhaps involve subclassing NSTextView and substituting your
>
subclass
>
for the window's field editor) and calling NSTabView's method for
>
activating
>
the next tab view item. There's an example in Vermont Recipes of using
>
this
>
NSTabView method from a navigation button.
>
>
>
--
>
>
Bill Cheeseman - email@hidden
>
Quechee Software, Quechee, Vermont, USA
>
>
The AppleScript Sourcebook - www.AppleScriptSourcebook.com
>
Vermont Recipes - www.stepwise.com/Articles/VermontRecipes
>
>
_______________________________________________
>
MacOSX-dev mailing list
>
email@hidden
>
http://www.omnigroup.com/mailman/listinfo/macosx-dev