0

In my OS X App, how can I change the NSTextField focus by pressing the Enter key instead of pressing the Tab key?

jscs
  • 63,694
  • 13
  • 151
  • 195
Max Colla
  • 61
  • 4

1 Answers1

1

You may use NSText - (void)textDidEndEditing:(NSNotification *)aNotification delegate method, where you should use NSWindow’s makeFirstResponder: to change the current first responder. See the NSResponder class reference for details on this.

First set delegate of your firs textField to self. Then in same class:

- (void)textDidEndEditing:(NSNotification *)aNotification {
     NSLog(@"delegate method");
    [self.window makeFirstResponder:[[[aNotification object]window]nextResponder]];
}

I assume that you do this in AppDelegate class.

Nikolai Nagornyi
  • 1,312
  • 2
  • 11
  • 26