Search code examples
cocoansviewnswindowfirst-responder

First responder problems


My application is a menu-bar app. It has a panel which holds another view. This view changes, and I each one of those should do it's own key-handling. When I change the first responder, only the current first responder get's the key-down notification, obviously.

But there should also be a global key-handling for the panel itself.

How am I supposed to do this? Multiple implementation is very ugly :)

Thanks


Solution

  • Ok, I have figured it out. I guess the superclass is calling the event-methods of the superview. Then the superview is notifying it's superview. And so on. If you call [super keyDown:theEvent]; it's done for you.

    - (void)keyDown:(NSEvent *)theEvent {
         [super keyDown:theEvent];
    
         // Do you your stuff here 
    }