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;
}
I believe you are looking for the NSControl delegate method:
Implement this method in your
NSTextField
delegate (easily set in IB).Then your request to change the responder, such as
should work.
where "view" is the parent NSView of your NSTextView control.
From the docs on the -resignFirstResponder method:
This code should do it:
I am no expert in iPhone programming yet but the method you need to implement is "textFieldShouldReturn" implemented like this: