This article describes how to open and close a window.
Opening—that is, making a window visible—is normally accomplished by placing the window into the application's window list by invoking one of the NSWindow
methods makeKeyAndOrderFront:
, orderFront:
, and so on. Also, with proper bits set in Interface Builder, the window is shown when the nib is loaded in some cases.
Closing a window involves explicit use of either the close
method, which simply removes the window from the screen, or performClose:
, which highlights the close button as though the user clicked it. Closing a window involves at least removing it from the screen but adds the possibility of disposing of it altogether. The setReleasedWhenClosed:
method specifies whether a window releases itself when it receives a close message. A window’s delegate is also notified when it’s about to close, as described in “Using Window Notifications and Delegate Methods.”
These methods hide a window without closing it. The method orderOut:
removes a window from the screen. You can also set a window to be removed from the screen automatically when its application isn’t active using setHidesOnDeactivate:
. And the isVisible
method tells whether a window is on or off the screen.
© 2002, 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-02-04)