Re: Switching between background <-> foreground app type at run-time
Re: Switching between background <-> foreground app type at run-time
- Subject: Re: Switching between background <-> foreground app type at run-time
- From: Mike Blaguszewski <email@hidden>
- Date: Wed, 26 Sep 2007 14:24:12 -0400
On Sep 26, 2007, at 2:06 PM, vance wrote:
How do I switch between BackgroundOnly (has no doc icon and menu)
and Foreground (has dock icon and menu) application at runtime,
both ways?
Basically you can't. Your summary of the options is pretty accurate.
1. Setting LSBackgroundOnly or LSUIElement in Info.plist to "1"
makes the application without a dock icon and menu.
I think this is the most reasonable solution, assuming your
configuration UI is relatively simple (single window). Make your
application an LSUIElement app (not LSBackgroundOnly) that uses
NSStatusItem. You can then bring up a window just like in any Cocoa
app, you just won't get a Dock icon or menu bar. I believe copy/paste/
etc. even work, but I can't remember for sure.
3. Have 2 different applications: One with LSBackgroundOnly set to
1, that creates the status item and Another one without
A variant on this is to have your NSStatusItem app set as
LSUIElement, and your non-background app be inside the main app's
bundle. Just add another target to your Xcode project, and it should
be reasonable to manage. You can do IPC using NSUserDefaults, -
[NSUserDefaults synchronize], and either watch for the NSWorkspace
notification that the GUI app has quit, or have the GUI app send an
NSDistributedNotification to tell the background app to resync its
prefs. (You may need to drop down to CFPreferences API to share the
user defaults this way.)
--
Mike Blaguszewski / Cocoa Hacker / Ambrosia Software, Inc.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden