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.
Asked
Active
Viewed 9,089 times
5

Axel Guilmin
- 11,454
- 9
- 54
- 64

Radu Paise
- 285
- 1
- 6
- 16
1 Answers
35
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.

Richard
- 3,316
- 30
- 41