Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top