5

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.

Axel Guilmin
  • 11,454
  • 9
  • 54
  • 64
Radu Paise
  • 285
  • 1
  • 6
  • 16

1 Answers1

35

There are several ways to be notified when a window closes.

  • You can observe NSWindowWillCloseNotification notifications from the second NSWindow object.
  • You can implement NSWindowDelegate methods windowShouldClose: or windowWillClose:.
  • You can subclass NSWindow and override the performClose: 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