• 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: keypress events + responder chain
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: keypress events + responder chain


  • Subject: Re: keypress events + responder chain
  • From: Buddy Kurz <email@hidden>
  • Date: Tue, 17 Oct 2006 07:39:58 -0700

I was able to use the following NSTextView delegate method to override the default handling of the escape key (auto-completion)
If someone has a better way, I am all ears.



- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL) aSelector {
if (aSelector==@selector(complete:)) {
//do something in response to escape key
return YES;
} else {
return NO;
}
}



I'm thinking you can get the window's field editor (see fieldEditor:forObject:) and set it's delegate



On Oct 17, 2006, at 1:08 AM, Alex Reynolds wrote:

I'd like to be able to track Escape keypresses but I can't seem to get any control over the responder chain. This is very frustrating.

I have a NSTextField in a subclassed NSWindow.

My NSWindow subclass contains a keyDown: method to see if the Escape button is pressed.

I connected the initialFirstResponder of my NSWindow subclass to the nib's File Owner.

When I first start the application, it responds to Escape keypresses.

If I click inside the NSTextField, I then lose the ability to track Escape keypresses.

How do I reconnect my NSWindow to the responder chain, or otherwise continue to be able to track Escape keypresses after clicking inside the NSTextField, or after clicking Tab to get outside the NSTextField?

If I set -resignFirstResponder to NO on my NSWindow subclass, I can keep tracking Escape keypresses, but now I can't click inside the NSTextField to modify its contents.

I also tried connecting the -nextKeyView outlet from the NSTextField to my subclassed NSWindow's NSView. This did not work. I could not Tab outside the NSTextField to regain the ability to track Escape keypresses.

Does anyone know how I could fix this?

Thanks for any advice,

Regards,
Alex
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >keypress events + responder chain (From: Alex Reynolds <email@hidden>)

  • Prev by Date: Re: Signed incoherences with NSTableView indexes
  • Next by Date: NSOutlineView Row Heights
  • Previous by thread: keypress events + responder chain
  • Next by thread: Re: keypress events + responder chain
  • Index(es):
    • Date
    • Thread