tags:

views:

33

answers:

1

I create a window in a helper tool that runs in the background (it's not an app bundle with a .nib and Info.plist, but a plain executable). When -makeKeyAndOrderFront: is called, the window is displayed but it does not "pop" out like an active window.

Can this be fixed?

Regards, Erik

+1  A: 

You should wrap the helper tool as a regular .app bundle with at least Info.plist. Then the problem goes away. A GUI app in OS X needs to have an Info.plist to receive events correctly.

The way a GUI app misbehaved if not in an app bundle has never been clear to me. If I remember correctly, it changed over time, depending on OS X's versions. I think it behaved worse in previous versions of OS X. For example, the window is shown but I couldn't click any UI inside it.

Many people who compiled a program in a cross-platform toolkit faced this problem, see e.g. this discussion here in the WxWidgets wiki. Apparently, OS X doesn't mark a program not within an .app bundle as a foreground-able app, which causes your problem. You can use TransformProcessType from your binary not inside an .app bundle to make a foreground-able app to solve your problem, but that's not a documented/intended usage of this function.

So, just wrap it in an .app bundle.

Update:

This "foreground-able-ness" is controlled by the activationPolicy of an app, see this doc on NSApplication. Found the info on this post on Cocoa with love.

Yuji
but when i click something in the window (e.g i have a table view there) and it becomes first responder, the window becomes active too.
Erik Aigner
I added a bit more info. See the edited answer.
Yuji
I know the activation policy flag, and I actually tried it before i wrote this question. But it didn't seem to work for my problem. However I've wrapped the thing in an app bundle now, so it should be fine.
Erik Aigner