RE: NSTextField controlTextDidEndEditing
RE: NSTextField controlTextDidEndEditing
- Subject: RE: NSTextField controlTextDidEndEditing
- From: Ulai Beekam <email@hidden>
- Date: Sat, 6 Mar 2010 01:57:32 +0000
- Importance: Normal
Sweet, thanks! I didn't even know of NSTextMovement, but doing a search for in Spotlight, I saw that it was indeed buried somewhere in the Event Handling Guide :)
So anyway, this is how I'm doing it now, and so far it seems to be working well:
- (void)controlTextDidEndEditing:(NSNotification *)aNotification
{
NSTextField *textField = [aNotification object];
NSView *nextKeyView = [textField nextKeyView];
NSUInteger whyEnd = [[[aNotification userInfo] objectForKey:@"NSTextMovement"] unsignedIntValue];
BOOL returnKeyPressed = (whyEnd == NSReturnTextMovement);
BOOL tabOrBacktabToSelf = ((whyEnd == NSTabTextMovement || whyEnd == NSBacktabTextMovement) && (nextKeyView == nil || nextKeyView == textField));
if (returnKeyPressed || tabOrBacktabToSelf)
NSLog(@"focus stays");
else
NSLog(@"focus leaves");
}
> NSText handles this properly; when it posts an NSTextDidEndEditingNotification, that includes NSTextMovement as a key. I'm not sure if NSControlTextDidEndEditingNotification is kind enough to pass that on too, or if you'll have to listen out for the original notification from the field editor.
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden