skip main content

Archive for May, 2010

nextKeyView and moving between NSTextfield and NSButton

posted by Duncan at 3:57 pm on May 26th, 2010

This caught me out today, so I thought I’d share to save someone else scratching their head. The problem I was having was thus. In interface builder I had a window with an NSTextField and an NSButton. I want to be able to tab between them. I did what I thought was correct:

  1. Set the intialFirstResponser for the NSWindow to be my NSTextField
  2. Set the NSTextField nextKeyView to be the NSButton
  3. Set the NSButton nextKeyView to be my NSTextField

But this was not working in the app! It Turns out that in the Apple > System Preferences > Keyboard there is a setting that allows you to press Tab to move keyboard focus between:

  • Text boxes and lists only
  • All controls

I think the top one is set by default. Once changed to All controls everything worked as expected.


back to the top