6
votes

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

1
Is your close button custom? do you run any other action on it?gmogames
nope it's the red close button in the top left corner of a standard NSWindow.Matthieu Riegler
maybe you can subclass NSWindow to try and override the performClose method.gmogames

1 Answers

18
votes

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