简体   繁体   English

当用户从finder中打开Cocoa应用程序时,打开一个窗口,而所有应用程序都准备好打开

[英]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. 我正在制作一个Cocoa menulet应用程序,但是我的用户要求一个不包含菜单的选项,然后在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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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