Get keyboard events in NSViewController

Discussion in 'Mac Programming' started by Ides, Nov 7, 2013.

  1. Ides macrumors member

    Joined:
    Mar 27, 2012
    #1
    I have an NSViewController subclass and I would like to be able to receive keyboard events. However, currently the methods keyUp: and keyDown: are not being called on this view controller when keys are pressed in my app. In my view controller subclass I have this code:

    Code:
     -(BOOL)acceptsFirstResponder {
    
         return YES;
    }
    AND
    Code:
    [self.view.window makeFirstResponder:self];
    
    But the keyUp: and keyDown: methods are still not called on my view controller. My view controller's view is visible and takes up most of the screen.
     
  2. ccamelot macrumors member

    ccamelot

    Joined:
    Feb 21, 2010
    Location:
    Poland
    #2
    Possible solution

    Hi Ides,

    please take a look at this post and linked gist

    hope it helps
    Les
     

Share This Page