Re: End Editing with RETURN
Re: End Editing with RETURN
- Subject: Re: End Editing with RETURN
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 05 Jun 2003 18:12:47 -0400
Greg, I can't find this in any documentation except for the NSText version
of -textDidEndEditing:. The documentation for the NSTextField version of
-textDidEndEditing: only refers to an NSFieldEditor key.
Are you saying that NSTextField's version of this delegate method responds
both to the NSTextMovement key and the NSFieldEditor key in its userInfo?
NSTextField does not inherit from NSText, although I realize that there is a
close relationship. Given the lack of an inheritance relationship, I would
think the documentation for NSTextField should mention this key, if this is
correct.
I ask, because I don't have time to test it just now.
on 03-06-05 3:24 PM, Greg Titus at email@hidden wrote:
>
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.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
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.