How to take notice when an NSWindow
is about to be opened or have just opened? That is, the opposite of windowWillClose:
delegate method (likewise the opposite of NSWindowWillCloseNotification.
)
This is related to this question, but from the other direction.
The background is, I'm looking to couple a window with a tickmark on the main menu (among other things). When the window is shown, the corresponding ̨ menu item should be checked and vice-versa.
It should not normally be a mystery when or how a window is made visible. It should only happen in response to something that your own code is doing. If the window is in a NIB and is marked Visible At Launch, then it shows when your code loads that NIB. Otherwise, it should only show if you call one of the -order...
methods other than -orderOut:
(e.g. -orderFront:
) or -makeKeyAndOrderFront:
. If the window is controlled by a window controller, then it would show if you invoke -[NSWindowController showWindow:]
. Etc.
If you really feel the need to be notified, you can subclass NSWindow
and override -orderWindow:relativeTo:
and, if orderingMode
is not NSWindowOut
and the window was not already visible, post a notification of your own.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With