close event NSWindow
I have an application, where a second NSWindow
is opened by pressing a button. This new window is opened using [NSApp runModalForWindow:<myWindow&开发者_如何学JAVAgt;]
. I want to be able to determine if the user closes the second window, in order to stop the modal.
There are several ways to be notified when a window closes.
- You can observe
NSWindowWillCloseNotification
notifications from the secondNSWindow
object. - You can implement
NSWindowDelegate
methodswindowShouldClose:
orwindowWillClose:
. - You can subclass
NSWindow
and override theperformClose:
method. - You can add a Close button to the window, and connect it to an action.
Without more information, it's hard to advise which of these or other options would work best for you.
精彩评论