Cocoa: NextKeyView - Tab Order


in my cocoa application I want to change the tab order of the controls so I can switch from a textfield to a button. I did connect the nextKeyView property of the textfield with the button but it seems to have no effect at all.

I already activated the appropriate system settings for Keyboard so I can tab to all controls now. It works fine but not in the order I set as nextKeyView.


You need to connect your window's initialFirstResponder outlet to at least 1 field. Some controls like NSTabView have one more initialResponder. So if you have anything inside tabview you need to connect them also. <strong>Overall logic is you need to connect all initialresponde to atleast 1 field</strong>


The answer provided by @sach solved this for me.

I created a new storyboard project, and added 3 text fields. I set a custom order by linking them together with nextKeyView in Interface Builder, but this had no effect at runtime. This is the simplest test case that I could come up with to replicate your (and my) problem.

To solve it using @sach's answer, create a new outlet and connect it to one of the NSTextFields:

@IBOutlet var firstTextField: NSTextField!

In the ViewController, I then added:

override func viewWillAppear() { // Must execute this after the window is connected self.view.window!.initialFirstResponder = nameField }

Re-run and the text fields cycle properly according to the order set using the nextKeyView links


  • Delphi - Capturing the Window/Form which has current focus
  • How to avoid sending Cookie header in java unirest requests?
  • I didn't close previous DataReader, but where?
  • performance overhead of typecasting variables in C [closed]
  • How to create mirrored image effect with CSS single element
  • No Gradle file syntax highlighting in Eclipse Mars.2
  • Failed to resolve: firebase-auth-15.0.0 [closed]
  • Can't hide status bar in AVPlayerViewController's portrait mode
  • Issues with converting data into a matrix after running lapply()
  • How do I change the names of buttons on a message box?
  • Example of using Service Exists MSBuild task in Microsoft.Sdc.Tasks?
  • Load php page results into div with ajax with link?
  • I need a PHP mySQL Login script that directs user to specific URL based on username and password
  • Signed Java web start application with Glassfish 4.1 and Java7
  • Scripting Support For Image Filtering in DigitalMicrograph
  • Sample deviceQuery cuda program
  • 'float' object cannot be interpreted as an integer
  • Admob in ListView not clickable
  • Unable to start a WebView from an AsyncTask
  • view details for exception in vs 2017
  • Haskell program that can handle any arbitrary deterministic finite automaton
  • Multiple table join MySQL multiple foreign keys
  • C# code can't “see” the methods in my C++ dll
  • how can i get selectedRange.location value?
  • Reload Page with Javascript after Database changes
  • How to resolve this in PHPUnit where it is asking me to set KERNEL_DIR in my phpunit.xml?
  • All Event listing on specified date in Google Calender api (V3) in java?
  • Swift: UIView.animate works unexpectedly
  • time column in sqlite using gorm
  • How to run chrome.tabs.insertCSS from the background page on each page?
  • how do i compare two rows and store the similarities of the two rows in another column
  • JavaScript Regex to Match Boundaries of Words with diacritics
  • Android: Unable to detect vertical plane
  • How do I add a mouse over tooltip to an Image using .DrawImage()
  • How to handle div that is created dynamically in a table
  • Debug `Unexpected end of JSON input Error` on content script
  • Apple Mach-O Linker error (“duplicate symbol”)
  • Sign a Pdf using custom digital signature in Java
  • Angular FormGroup won't update it's value immediately after patchValue or setValue