Re: End Editing with RETURN
Re: End Editing with RETURN
- Subject: Re: End Editing with RETURN
- From: Greg Titus <email@hidden>
- Date: Thu, 5 Jun 2003 12:24:42 -0700
On Thursday, June 5, 2003, at 11:18 AM, Lorenzo wrote:
Hi,
I have some NSTextFields (of my subclass) in a Window.
I want that when the user presses RETURN, more than ending the
editing, I
perform an action. I found the delegate methods very useful.
Anyway, the following
- (void)textDidEndEditing:(NSNotification *)aNotification
{
NSLog(@"textDidEndEditing");
}
has been executed any time the user presses TAB or RETURN.
How could I detect the user ended to edit the field pressing a RETURN?
Is this info nested inside the aNotification
Yep. It is in the "NSTextMovement" key in the notification userInfo
dictionary. So your code should look something like:
- (void)textDidEndEditing:(NSNotification *)aNotification
{
if ([[[aNotification userInfo] objectForKey:@"NSTextMovement"]
intValue] == NSReturnTextMovement) {
// pressed return
} else {
// used tab or backtab
}
}
Hope this helps,
- Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.