How to make action to close NSPopover?

北城以北 提交于 2019-12-08 14:58:14

问题


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?


回答1:


I solved the problem!

  • First go ahead and click your .xib file.
  • Where you see the first responder box and files owner - click on the popover.
  • On the sidebar go to the attributes center
  • Change the behavior from Application-Defined to Transient and it should work!

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

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:



来源:https://stackoverflow.com/questions/7294976/how-to-make-action-to-close-nspopover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!