I have a delegate of NSTextField that uses the controlTextDidEndEditing: method
to do some stuff when the editing has finished.
However, there are (as far as I can imagine) two types of possible scenarios
under which the editing finishes: 1) the user hits return. in this case, the
focus stays on the text field. 2) the user presses tab or clicks someplace
else, in which case the text field loses focus.
My question is: What is the proper way to know *within the
controlTextDidEndEditing: delegate method* which of the two scenarios occurred
(or will occur? i suppose it has already occurred since it's a "Did" method)?
This is how I'm currently doing it, and it is not working properly:
- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
NSTextField *textField = [aNotification object];
NSTextView *fieldEditor = [[aNotification userInfo]
objectForKey:@"NSFieldEditor"];
if ([[textField window] firstResponder] == fieldEditor)
NSLog(@"focus lost");
else
NSLog(@"focus retained");
}
This works only in that if the user *clicks* outside the text field, "focus
lost" is printed, and if the user hits return, "focus retained" is printed.
However, this *fails* when I tab out of the text field, in which case "focus
retained" is printed, which obviously indicated that my way of doing this sucks.
So I'm all out of luck. Any ideas?
Thanks, U.
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]