简体   繁体   English

Swift-单击菜单外部时NSMenu关闭

[英]Swift - NSMenu closes when clicking outside of menu

so i have a simple NSMenu. 所以我有一个简单的NSMenu。 It is attached to a Status Item Button. 它连接到状态项按钮。 When i click the Button it pops Open. 当我单击按钮时,它弹出打开。 Now my Problem is that as soon as i click outside of the NSMenu, it closes. 现在我的问题是,一旦我在NSMenu外部单击,它就会关闭。 How can i avoid that ? 我如何避免这种情况? I did try many things but cant get that to work. 我确实尝试了很多事情,但无法使它起作用。

The reason i need that is that when the user clicks something in the NSMenu, another window opens, and while this window is open i also want the NSMenu to stay open. 我需要的原因是,当用户单击NSMenu中的某个内容时,会打开另一个窗口,并且当此窗口打开时,我也希望NSMenu保持打开状态。 But it just does not work. 但这是行不通的。

I feel like its impossible. 我觉得这不可能。

Many Thanks in advance. 提前谢谢了。

我相信您必须创建一个弹出的自定义视图,但是可以使用NSMenu在本地完成某些操作。

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

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