I wasn't sure if this should go to carbon-dev or cocoa-dev, but
ultimately since this is a pretty low-level API and I suspect my
problem interacts with Cocoa, I figured cocoa-dev would do.

I have an application which I would like to function in both
"background" and "foreground" mode. Basically, when launched from
login items (or when relaunching itself) it will be in background
mode, presenting little UI and watching user actions to display helper
windows when appropriate. When explicitly double-clicked from the
Finder, it will pop up a Dock icon and a menu bar and such and act
like a normal application so the user can set preferences and the
like.

I know that the "standard" way to do this is to have two apps. I'd
really like to avoid this if I can. I've done it before, and it was
less than fun. Seems like having a single app that switches modes
ought to work, in any case.

So, the actual problem: I set LSUIElement to 1 in my Info.plist and
use TransformProcessType to bump to a foreground application. This
works except that it fails to show my app's menu bar. Switching to
another program and back to mine makes it show correctly.

I've tried using LSBackgroundOnly, SetFrontProcess, [NSApp
activateIgnoringOtherApps:YES], and none of them change things. I even
tried to manually perform the switch to another app, by doing
GetFrontProcess beforehand, then setting it front and then my own. No
dice.

I finally stumbled upon a partial workaround. If I do
TransformProcessType/SetFrontProcess in main() before the call to
NSApplicationMain(), it works as expected. But only if I launch from
Finder, not Xcode. The behavior when launched from Finder is just what
I want so I'm somewhat happy, but the continuing broken behavior in
Xcode makes me worry.

Apparently I'm not the only one to hit this problem:

http://www.cocoabuilder.com/archive/message/cocoa/2007/11/14/193082

Alas, no solutions there.

So, does anyone know what's going on, or a better workaround than the
partial one I've managed to find?

Mike
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to