I have a NSWindow
that goes into full screen. My NSWindowController
is an observer of the NSWindowWillCloseNotification
notification.
I would like to do something special when the window is closed (As in the user presses the red X button in the top left hand corner) but I also get the NSWindowWillCloseNotification
notification when the user leaves full screen mode, in which case I do not want anything to happen.
Is there a way to determine inside of the selector I set up to be called when I observe the NSWindowWillCloseNotification
notification? At the point my selector is called, the NSWindow
has already left full screen, so I cannot check if it is full screen or not. Also the NSNotifications
's UserInfo dictionary is nil.
Thanks,
Will
Turns out I was getting the notification from a window that wasn't my
NSWindowController
's window!Printing out the notification that I was receiving we can see that I was getting the
NSWindowWillCloseNotification
call for aNSToolbarFullScreenWindow
:NSConcreteNotification 0x6080002578b0 {name = NSWindowWillCloseNotification; object = <NSToolbarFullScreenWindow: 0x100d57f50>}
I should have wrote my observer method like this, rather than passing
nil
for object:[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleWindowWillClose:) name:NSWindowWillCloseNotification object:self.window];