9

Is there an easy way to know when a NSWindow was closed using the close button (of the window title bar) .

Using NSWindowDelegate and the windowWillClose:(NSNotification *)notification method I get notification of each closing. But how can I know the closing request was send by the close button

Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134

1 Answers1

21

Use [yourWindow standardWindowButton:NSWindowCloseButton] to find the close button, then change its target and action to a custom method.

andyvn22
  • 14,696
  • 1
  • 52
  • 74