简体   繁体   English

状态栏应用程序中的OS X显示窗口

[英]OS X Display Window from a Status Bar Application

I'm writing a small application that runs as a OS X status bar app, and what to be able to create a preferences window from the app. 我正在编写一个作为OS X状态栏应用程序运行的小型应用程序,以及能够从该应用程序创建首选项窗口的内容。 I'm able to create and display the window, but it always appears underneath other windows. 我可以创建和显示该窗口,但它始终显示在其他窗口的下方。 I've created the window in the main .xib file, and assigned to the window property of my app delegate. 我已经在主.xib文件中创建了窗口,并将其分配给我的应用程序委托的window属性。 When I want to display the preferences window, I do this: 当我要显示首选项窗口时,请执行以下操作:

[window makeKeyAndOrderFront:self];

As mentioned above, this seems to add the window to the back of stack of windows. 如上所述,这似乎将窗口添加到窗口堆栈的后面。 I've tried a variety of the layer method too, and none seem to change that. 我也尝试了多种分层方法,但似乎都没有改变。

Any help would be appreciated. 任何帮助,将不胜感激。

I had this exact problem a while back. 我前一段时间有这个确切的问题。 makeKeyAndOrderFront: only brings the window to the front of the application, you need to bring the entire application to the front by calling makeKeyAndOrderFront:仅将窗口置于应用程序的最前面,您需要通过调用将整个应用程序置于最前面

[NSApp activateIgnoringOtherApps:YES];

after makeKeyAndOrderFront: . makeKeyAndOrderFront:

Happy coding! 编码愉快!
Billy 比利

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

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