如何采取行动关闭 NSPopover? [英] How to make action to close NSPopover?

查看:33
本文介绍了如何采取行动关闭 NSPopover?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的一个应用程序中实现了 NSPopover,但弹出窗口不会关闭.我猜它应该在我点击其他东西后关闭,但它不是.我知道有一个 close popover 动作,但这只适用于不同的按钮.当我按下同一个按钮时,我怎样才能看到弹出框是打开的,当它打开时关闭弹出框?

Hi I implemented an NSPopover in one of my apps, but the popover will not close. I'm guessing that it should close once I click something else, but its not. I know that there's a close popover action but that only works for a different button. How can I make it look to see that the popover is open and when it is open to close the popover when I press the same button?

推荐答案

我解决了问题!

  • 首先点击您的 .xib 文件.
  • 在您看到第一响应者框和文件所有者的位置 - 点击弹出框.
  • 在侧边栏上转到属性中心
  • 将行为从应用程序定义更改为瞬态,它应该可以工作!

一旦有人点击弹出框外,这应该会使弹出框消失.

That should make the popover disappear once someone has clicked outside the popover.

另一种关闭弹出框的方法是使用单独的按钮.只需添加另一个 NSButton,然后将其链接到侧边栏上的弹​​出框并将其设置为 Received actions -> perform close:

Another way to close the popover is to have a separate button. Just add another NSButton and then link it to the popover on the sidebar and set it to Received actions -> perform close:

这篇关于如何采取行动关闭 NSPopover?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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