Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I know NSWindow was closed using the close button ?

Tags:

cocoa

nswindow

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

like image 951
Matthieu Riegler Avatar asked Jul 16 '12 23:07

Matthieu Riegler


1 Answers

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

like image 84
andyvn22 Avatar answered Oct 20 '22 00:10

andyvn22