Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>]. I want to be able to determine if the user closes the second window, in order to stop the modal.

like image 880
Radu Paise Avatar asked Feb 24 '11 20:02

Radu Paise


1 Answers

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.

like image 75
Richard Avatar answered Nov 08 '22 05:11

Richard