简体   繁体   中英

Open a window when user opens Cocoa app from finder, while app all ready open

I'm making a Cocoa menulet app, but my users have requested an option to not have the menu, and open the preferences by double clicking the app in Finder. Also the window can't open when the app first launches. (Only shows window when app already open.)

How would I go about this? I've looked all over the internet, but it seems I'm not googling the correct words. I'm sure it's a very simple thing to do.

Okay figured it out...

Use this:

- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag{
    [window makeKeyAndOrderFront:nil];
    return YES;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM