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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to