如何让NSPopover的分离窗口成为模态窗口
在 MAC OS X 10.7 中,Apple 引入了一个名为 NSPopover 的新类,您甚至可以拖走该弹出窗口视图以成为独立的 NSWindow。但是,我想阻止用户与主窗口交互,直到关闭分离的窗口。我怎样才能安全地做到这一点?
实际上,一个更常见(甚至更愚蠢)的问题应该是,如何防止任何用户交互,直到当前前窗口返回?我也不懂编程。
In MAC OS X 10.7, Apple introduced a new class called NSPopover and you can even drag away that popover view to become an independent NSWindow. However, I want to prevent user interaction to the main window until the detached window is closed. How can I safely do this?
Actually, a more common (and even more stupid) question should be, how to prevent any user interaction until current front window returns? I am noob to tread programming also.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己找到了解决方案。现在看起来工作正常。
为此,在将分离的窗口排序到前面并成为关键窗口之后,以下代码将使其成为模态窗口(其中 currModalSession 是我自己定义的 iVar)。
此外,您必须结束已打开的每个模态会话。因此,以下代码可以完成这项工作:
注意: 您必须在此处使用 Modal Session 而不是 runModalForWindow,原因有两个:
I kind of found the solution myself. It looks working fine now.
To do this, after the detached window ordered to front and become key window, the following code will make it a modal window (where currModalSession is an iVar defined by myself).
Also, you have to end each Modal Session you have opened. So the following code does the job:
Note: you have to use Modal Session here rather than runModalForWindow for two reasons: