Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX: Move keyboard focus between textfields and buttons using tab key

I am trying to toggle between textfields and buttons on my view using keyboard's tab button. The switching between textfields work but it does not switch between buttons. The view is shown as below.I did not find enough resources online to proceed further. Does anyone know how to resolve this?

enter image description here

like image 312
Obj-Swift Avatar asked Sep 24 '15 21:09

Obj-Swift


2 Answers

There is nothing you can do with that issue. It turns out that in the System Preferences > Keyboard > Shortcuts there is a checkbox, where you can change behaviour of the whole system:

  • To move keyboard focus only between text boxes and lists
  • To move keyboard between any of controls

And by default first checkbox is pressed.

As an addition. By default, NSWindow assigns an initial first responder and constructs a key view loop with the objects it finds. You can also change key view loop by calling this method: setNextKeyView. For example,

[firstTextBox setNextKeyView:secondTextBox];
[secondTextBox setNextKeyView:secondButton];
[secondButton setNextKeyView:firstButton];
[firstButton setNextKeyView:firstTextBox];

This means that for users who expect moving control focus through all controls, this will work. And for those who have disabled this feature in settings, this won't work.

like image 112
markvasiv Avatar answered Sep 22 '22 02:09

markvasiv


You can right-click on text field, drag "nextKeyView" and drop on another text field that you want to focus next when user press tab. Look like my picture below:
add tab action for text field

like image 20
Heo Đất Hades Avatar answered Sep 19 '22 02:09

Heo Đất Hades