Keyboard event on windowsController

Discussion in 'Mac Programming' started by consoleart, Sep 24, 2014.

  1. consoleart macrumors newbie

    Joined:
    Sep 23, 2014
    #1
    I have a clarification WRT to a NSWINDOWSCONTROLLER class, how do i add a keydown event to the windows controller class. i assume i need a NSVIEW subclass for the keydown events to fire, but my current class is subclassed from nswindowscontroller because its a multiple window application.
     
  2. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #2
    The docs say that NSWindowController inherits from NSResponder so theoretically it can respond to events.

    I would read up on the NSResponder class as a reference. Read the Mac OS Cocoa Event Handling Guide to read about the design of Events in Cocoa apps. It will talk about the Responder Chain and how it works.
     
  3. consoleart thread starter macrumors newbie

    Joined:
    Sep 23, 2014
    #3
    hi, yes, it responded, i was trying keying in some text inside a NSTEXTview and the event was not firing, and managed to wire the events now by inheriting the textview and calling a method from there to the parent class.

    Thanks for the comments.
     
  4. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #4
    Another option would be to make your responder the "First Responder". Then you could decide which keys to handle and which ones to not handle. You wouldn't have to mess with the text field at all.
     

Share This Page