• 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
[SOLVED] Re: NSTextView and keyDown: in the responder chain
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED] Re: NSTextView and keyDown: in the responder chain


  • Subject: [SOLVED] Re: NSTextView and keyDown: in the responder chain
  • From: Tom <email@hidden>
  • Date: Fri, 13 Feb 2009 16:20:11 +1000


On 13/02/2009, at 1:58 AM, Ross Carter wrote:


On Feb 11, 2009, at 10:21 PM, Tom wrote:

However, I've found that when an NSTextView receives a keyDown event that doesn't handle, it doesn't bother to send the event down the responder chain and just calls NSBeep().

I expect that there isn't a keyDown event that NSTextView doesn't handle. It sends them all to -interpretKeyEvents. The events go through the system input manager and get back to the NSTextView in the form of -insertText: or -doCommandBySelector:. It is doCommandBySelector: that is firing the beep. You can set a breakpoint on NSBeep to see the call stack.


Ross

You were spot on, Ross. Thanks for the help. Instead of keyDown: being passed down the responder chain it is doCommandBySelector:.


The solution I've used is to override doCommandBySelector: and convert it back into a keyDown: call in the last responder in the chain. Here's the code:

- (void)doCommandBySelector:(SEL)aSelector
{
	NSEvent* e = [NSApp currentEvent];
	if([e type] == NSKeyDown){
		[self keyDown:e];
	} else {
		[super doCommandBySelector:aSelector];
	}
}

Kind regards,

Tom





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSTextView and keyDown: in the responder chain (From: Tom <email@hidden>)
 >Re: NSTextView and keyDown: in the responder chain (From: Graham Cox <email@hidden>)
 >Re: NSTextView and keyDown: in the responder chain (From: Tom <email@hidden>)
 >Re: NSTextView and keyDown: in the responder chain (From: Ross Carter <email@hidden>)

  • Prev by Date: Re: CALayer wierdness
  • Next by Date: Matching String With ObjectForKey?
  • Previous by thread: Re: NSTextView and keyDown: in the responder chain
  • Next by thread: Cocoa application won't die
  • Index(es):
    • Date
    • Thread