Window does not receive keyboard events

Discussion in 'Mac Programming' started by bsabiston, Jun 7, 2013.

  1. bsabiston, Jun 7, 2013
    Last edited: Jun 7, 2013

    bsabiston macrumors newbie

    Jun 7, 2013

    I have an OSX app which I started by modifying some sample code. It's an OpenGL app with a single window.

    I have two screens on my computer, and I notice that if I drag the app's window to the second screen, it continues to open there when I relaunch. Further, if I use the green minimize button, the window fills the second screen. After I do that, every time I launch it comes up in that configuration. Is that just something XCode does?

    The real question is this: Originally the 'Title Bar' setting was checked for the window. I unchecked it to see what would happen, and the app now fills my second screen. The only problem is that keyboard events no longer seem to go to the app. The computer just beeps when I hit keys. Before, when I had 'Title Bar' checked, the keyboard events worked fine.

    So how do I have no Title Bar for the window but still have the window receive my keyboard events?

    I was reading some of the documentation and tried adding all of these to my custom NSOpenGLView code:

    -(BOOL)becomeFirstResponder {
    return YES;

    -(BOOL)resignFirstResponder {

    return YES;

    -(BOOL)canBecomeKeyView {
    return YES;

    - (BOOL)acceptsFirstResponder {
    return YES;

    Some of those were already there. But the window still doesn't receive keyboard events unless I have ''Title Bar' checked.

    I tried dragging a connection between the window 'initialFirstResponder' outlet to the view, but that also did not do anything.

    Does anyone know what I need to do? Is the problem that I need to modify the window code and not the view? The app doesn't have any kind of custom window class -- only the NSOpenGLView.

    Thanks for any suggestions!

Share This Page