Cocoa window focus

Member
Posts: 198
Joined: 2005.01
Post: #1
Ok, this is probably going to sound like the dumbest question anyone's asked on here yet. Grin But here goes...

I've got a single OpenGL view window that's created via the my project's NIB. I just size the contents to 640x480, put an NSView inside it, and attach to that at start time to make the GL context. It all works just great, except that the window is never focused when the app starts.

I've tried messing around with IB properties, I've tried all sorts of different methods I found in the Xcode docs for manually raising and focusing windows... nothing seems to work. I get key input just fine, and once the window is up you can click on it to focus it. It just won't focus by default, which looks goofy.

To add insult to injury, I wrote an OpenVPN Cocoa front end that works just fine. So it's not like I'm tainted with the window non-focus in general Smile

Is there something I'm missing here? Wacko

The only thing I can think of that I'm doing weirdly is I've got my own event loop... but it passes all events it doesn't understand onwards using [NSApp sendEvent:].

Cryptic Allusion Games / Cryptic Allusion, LLC
http://www.cagames.com/
Quote this message in a reply
Member
Posts: 304
Joined: 2002.04
Post: #2
well after you awake from NIB you can:
[myWindow makeKeyAndOrderFront:nil];
[myWindow makeFirstResponder:myView];

obviously myWindow and myView are outlets you need to connect to the window and view. Does that work?
Quote this message in a reply
Member
Posts: 198
Joined: 2005.01
Post: #3
I'm about 90% sure I tried both of those before, but now it seems to work. Blink Maybe I was doing something silly like trying to use them on the view...

Anyway, thanks!

Cryptic Allusion Games / Cryptic Allusion, LLC
http://www.cagames.com/
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Tao.Sdl and window input focus scgames 6 4,947 Apr 6, 2008 06:49 PM
Last Post: Duane
  Continuous Mouse Input and Keeping Focus Nevada 4 3,226 Aug 30, 2007 05:09 PM
Last Post: AnotherJake
  xCode see when the windows looses focus guvidu 1 2,476 Mar 23, 2007 04:25 AM
Last Post: OneSadCookie