Display Cocoa application settings when you click on the application icon again

For a background application (LSUIElement = 1), what is the most elegant way to make its “preferences” or “configuration” window appear if the user double-clicks the application icon during its launch?

It is assumed that the user cannot access application prefixes from anywhere else (for example, the menu of menu items).

I would suggest that the ideal method would prevent the prefs window from showing on initial startup, but smart enough to show it on subsequent double-clicks on the application icon.

thanks

+4
source share
1 answer

You just need to implement the NSApplicationDelegate applicationShouldHandleReopen:hasVisibleWindows: protocol method.

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

would be enough; this delegate method is called only when the application is reopened.

+6
source

All Articles