NSWindow 关闭事件
我有一个应用程序,通过按下按钮打开第二个 NSWindow 。这个新窗口是使用 [NSApp runModalForWindow:
打开的。我希望能够确定用户是否关闭第二个窗口,以便停止模式。
I have an application, where a second NSWindow
is opened by pressing a button. This new window is opened using [NSApp runModalForWindow:<myWindow>]
. I want to be able to determine if the user closes the second window, in order to stop the modal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
窗口关闭时有多种方式可以收到通知。
NSWindow
对象观察NSWindowWillCloseNotification
通知。NSWindowDelegate
方法windowShouldClose:
或windowWillClose:
。NSWindow
并重写performClose:
方法。如果没有更多信息,很难建议这些或其他选项中哪一个最适合您。
There are several ways to be notified when a window closes.
NSWindowWillCloseNotification
notifications from the secondNSWindow
object.NSWindowDelegate
methodswindowShouldClose:
orwindowWillClose:
.NSWindow
and override theperformClose:
method.Without more information, it's hard to advise which of these or other options would work best for you.