tags:

views:

20

answers:

1

For a background app (LSUIElement=1), what's the most elegant way to make its 'preferences' or 'configuration' window pop up if a user double-clicks the app icon while it's already running?

This is assuming the user cannot access the app's prefs from anywhere else (such as menu bar status item menus).

I would suppose the ideal method would prevent the prefs window from showing on initial start, but is smart enough to show it on subsequent double-clicks on the app's icon.

Thanks

+3  A: 

You just have to implement an NSApplicationDelegate protocol method applicationShouldHandleReopen:hasVisibleWindows:.

- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
{
     // open pref pane
     return NO;
}

would suffice; this delegate method is only called when the app is re-opened.

Yuji
So obvious now! I went over the NSApplicationDelegate protocol and completely missed this one. That's for coding past 2am :)
the979kid