Pressing tab in NSTextField selects all text inste

2019-04-10 08:41发布

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.

1条回答
▲ chillily
2楼-- · 2019-04-10 09:31

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

查看更多
登录 后发表回答