I'm trying to have my text field resign first responder when the user is done editing it, like when they hit enter. The delegate method is getting called but what I have now doesn't work, what is the proper way to go about doing this?
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
[fieldEditor resignFirstResponder];
return YES;
}
From the docs on the -resignFirstResponder method:
Use the NSWindow makeFirstResponder: method, not this method, to make an object the first responder. Never invoke this method directly.
This code should do it:
[myWindow makeFirstResponder:nil];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With