• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Making Esc abort text editing in a NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Making Esc abort text editing in a NSTextField (From: Pierre-Olivier Latour <email@hidden>)

  • Prev by Date: Re: NSProgressIndicator in 10.2: Buggy?
  • Next by Date: Re: cocoa-dev digest, Vol 2 #1168 - 15 msgs
  • Previous by thread: Making Esc abort text editing in a NSTextField
  • Next by thread: NSProgressIndicator in 10.2: Buggy?
  • Index(es):
    • Date
    • Thread