Re: Making Esc abort text editing in a NSTextField
Re: Making Esc abort text editing in a NSTextField
- Subject: Re: Making Esc abort text editing in a NSTextField
- From: Douglas Davidson <email@hidden>
- Date: Thu, 29 Aug 2002 09:27:42 -0700
On Thursday, August 29, 2002, at 07:56 AM, Pierre-Olivier Latour wrote:
I've got a problem that's driving me nuts:
I'm temporary creating a NSTextField in a view so that the user can
change
the value of some text in a drawing. When he's done, he presses return
or
click elsewhere, the textfield is destroyed, and the new value
replaces the
old one in the drawing.
I'd like to call "[... abortEditing]" when the user presses the Esc
key.
Because right now, whatever you do, you cannot quit the textfield
without
confirming the value that's inside it. Very annoying.
Is there any way to do this without intercepting events at the window
level?
I tried to subclass NSTextfield, watching for keyDown event, insert
characters or whatever without success :-/
The usual answer to questions like this is: delegate.
The control's delegate can implement
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView
doCommandBySelector:(SEL)commandSelector;
and look for the appropriate selector--in this case, @selector(cancel:).
Douglas Davidson
_______________________________________________
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.