Tab Order in interface builder?
Asked Answered
F

3

22

Perhaps the hour is late, but I can't find where I can set the overall Tab Order of my interface viewer dialog, just like I can with Visual Studio.

am I missing something? The tab order is all crooked. Command-R to simulate shows it.

Fer answered 23/11, 2010 at 22:54 Comment(1)
Please edit your question to include a screenshot of the “tab order” you're referring to, and what you find “crooked”.Gullible
J
39

The Cocoa term you're looking for is "key view loop". Use the initialFirstResponder and nextKeyView outlets to connect the views together in the order you'd like to tab through them.

This is mentioned in the documentation here.

Note that the items which can receive keyboard focus will change depending on the Full Keyboard Access setting (in System Preferences > Keyboard); if disabled, tabbing will skip over various items in your key view loop.

Judithjuditha answered 24/11, 2010 at 2:8 Comment(5)
Thanks. Is there a way to set the order from the Interface builder itself? I mean, if you just build something from scratch it will have a given tab order, based i believe on the order of the control creation. If i add the last control in the "first position" on the view itself, it will still be last although it looks as if it should have been first. I guess my question is whether there's a way to tweak that ordering from interface builder itself, not programmatically if possible.Fer
Yes, when I say "outlets...connect the views together" I'm talking about stuff you can do from Interface Builder. You use the window's initialFirstResponder's outlet to set the "first position".Judithjuditha
For posterity, a gist that highlights the current first responder and prints the key-view loop in the console: gist.github.com/mittsh/6668638Hereinto
Hi will it be depend on OSX version.. because tab order working by default in 10.9.2 OSX but not working in 10.8.5 OSX.. any help please.Sphacelus
Also, make sure "Refuses First Responder" is not disabled in IB.Dowitcher
C
2

Let the outlets are named as a, b and c. Mac default tab order is a -> b -> c -> a

But Your desired tab order is a -> c -> b ->a :

enter image description here

Using IB:

Set a as the initialFirstResponder.

Then put the nextKeyView accordingly as a to c, c to b and c to a.

But I prefer using codes, here it become easier to add more. As in complex UI there may be 30+ controls and you might require to shuffle and even insert new control!!!

So you can achieve the same as :

[self.a setNextKeyView:self.c];
[self.c setNextKeyView:self.b];
[self.b setNextKeyView:self.a];
Candlefish answered 14/11, 2014 at 13:46 Comment(2)
This does not work when some of the views are hidden by default, and become visible later.Shrivel
@Etan: for such cases you need to take care by setting its nextKeyView runtime based on what view is visible(on top).Candlefish
S
0

I have found that placing the group of textfields in a separate view will help control the order in which the elements get their focus.

I tested in the simulator and on an iPad. It worked well for me.

Suspension answered 31/8, 2018 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.