Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choosing the order that text fields cycle when tab is pressed

I have several text fields and would like to set a particular order in which they would cycle when the tab key is pressed. Currently, it starts at a text field with becomeFirstResponder and then goes on in the default order which xcode put. Can I somehow bypass that order and force the text fields to cycle in a particular order? Like linking the last one of the cycle back to the first one.

Thanks for the help.

like image 443
Elbimio Avatar asked Jan 20 '23 06:01

Elbimio


2 Answers

Connect the initialFirstResponder outlet of your window to the first text field, then build a chain by connecting the nextKeyView outlet of that text field to the text field that should come next (and so on).

like image 132
omz Avatar answered Jan 21 '23 20:01

omz


That's called the key view loop.

like image 28
Peter Hosey Avatar answered Jan 21 '23 19:01

Peter Hosey