Close NSWindow Event

I have an application where the second NSWindow opens with the click of a button. This new window opens with [NSApp runModalForWindow:<myWindow>] . I want to determine if the user closes the second window to stop the modal.

+4
source share
1 answer

There are several notification methods when closing a window.

  • You can observe NSWindowWillCloseNotification notifications from the second NSWindow object.
  • You can implement the NSWindowDelegate windowShouldClose: or windowWillClose: .
  • You can subclass NSWindow and override the performClose: method.
  • You can add the Close button to the window and connect it to the action.

Without additional information, it’s hard to tell which of these or other options will work best for you.

+25
source

Source: https://habr.com/ru/post/1341207/


All Articles