Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pressing tab in NSTextField selects all text instead of going to next control

I have multiple views all work fine but for some reason a view does not focus the next control when typing the tab key. Instead it selects all text of the current NSTextField.

I am forgetting something really stupid here; can anyone help me on this?

So it's an NIB containing a NSView. On the view are two NSTextFields, pressing tab in one will not advance to next but instead select all text in current.

like image 410
Ger Teunis Avatar asked Dec 17 '22 03:12

Ger Teunis


1 Answers

I've found it myself. For anyone in the future having a similar problem:

If you are going to dynamic replace views in a NSWindow or NSView using addSubView or replaceSubView command you need to tell the NSWindow to recalculate the ViewLoop using NSWindow's recalculateKeyViewLoop or setAutorecalculatesKeyViewLoop

More info here: http://www.cocoabuilder.com/archive/cocoa/195341-nested-nsviews-and-keyboard-focus.html

like image 57
Ger Teunis Avatar answered Dec 27 '22 10:12

Ger Teunis