I'm working on an NSWindow
subclass and I'm running into some strange behavior that makes me question some of my assumptions about how windows work on Mac OS X.
What precisely happens to NSWindow
instances when [[NSApplication sharedApplication] hide: self]
is called?
All windows that do not return NO to -(BOOL)canHide
disappear from the screen. Then all windows re-appear when the application becomes active or [NSApplication sharedApplication] unhide: self]
is called.
I had assumed that this would be achieved by taking a snapshot of the current window state, then calling orderOut:
on all NSWindow
instances and then performing the whole thing backwards when unhide:
is called.
That does not seem to be the case, however. The orderOut:
method of my NSWindow
subclass isn't called.. in fact it's not hidden either. It does set setCanHide:
to YES though.. what's happening?
Any insights would be very much appreciated.
Best regards,
Frank
Fire up Instruments and find out for yourself! On my machine (10.6.4) and a 32-Bit application, [NSApplication hide:]
calls ShowHideProcess
. It's documented there:
The ShowHideProcess
then calls CPSPostHideReq
(something in CoreGraphics).
But there is no orderOut:, actually no objc_msgSend()
at all.
What do you need it for? Or were you just curious? Because for most cases, you should do just fine listening for the NSApplicationWill/DidHideNotification
.