可可-如何从StatusMenu进入特定窗口 [英] Cocoa - How to bring particular window to come in foreground from StatusMenu

查看:135
本文介绍了可可-如何从StatusMenu进入特定窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Mac应用程序.我已经在plist中设置了Application is agent (UIElement) = YES,并且App具有一个窗口(让我们说弹出窗口),该窗口充当StatusMenu的自定义PopOver. (让我们说B窗口)还有一个窗口,当我从StatusMenu中选择一个链接时应打开该窗口,但是我面临的问题如下:

I am working on an Mac Application. I have set Application is agent (UIElement) = YES in plist, and App have a Window (lets say Popup Window) that acts as custom PopOver for StatusMenu. One more window is there (lets say Window B) that should opened on selecting a Link from StatusMenu that i have made, but Problems that I am facing are as follow:

  • 在应用程序启动时,当我 打开状态菜单同时显示窗口B 时,实际上不应该显示该窗口.窗口B已在Application Delegate中分配并初始化.

  • On Application launch, When I opens status Menu It also showing Window B, that actually should not be Shown. Window B is allocated and initialised in Application Delegate.

另一个问题是,通过从StatusMenu中选择窗口B使其可见.看起来不错,现在我切换到另一个应用程序,因此它的窗口发送到了后台,很好, ,但是每当我单击状态菜单时,它就会自动出现在前端. 它应该只打开弹出窗口.

Another Issue is When Window B is made Visible by Selecting it from StatusMenu. It appears well, Now i switch to another application so Its window is sent to background that is fine, but Whenever I click on Status Menu, It automatically comes in Front. Ideally It should only open Popup window.

推荐答案

  • 窗口B正在打开,因为您可能会忘记在界面构建器的属性检查器中取消选中启动时可见"窗口属性
    • 第二个问题,您可以通过在调用窗口之前将ActivateIgnoringOtherApps设置为YES来解决

    • 2nd issue you can resolve by activateIgnoringOtherApps set to YES before calling your window

    [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
    
    [windowB showWindow:nil];
    

    这篇关于可可-如何从StatusMenu进入特定窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆