Mac Developer Library

Developer

AppKit Framework Reference NSWindow Class Reference

Options
Deployment Target:

On This Page
Language:

NSWindow

The NSWindow class defines objects (known as windows) that manage and coordinate the windows an application displays on the screen. A single NSWindow object corresponds to at most one onscreen window. The two principal functions of a window are to provide an area in which views can be placed and to accept and distribute, to the appropriate views, events the user instigates through actions with the mouse and keyboard.

  • Creates a titled window that contains the specified content view controller.

    Declaration

    Swift

    convenience init(contentViewController contentViewController: NSViewController)

    Objective-C

    + (instancetype)windowWithContentViewController:(NSViewController *)contentViewController

    Parameters

    contentViewController

    The view controller that provides the main content view for the window. The window’s contentView property is set to contentViewController.view.

    Return Value

    A window with the content view controller set to the passed-in view controller object.

    Discussion

    This method creates a basic window object that is titled, closable, resizable, and miniaturizable. By default, the window's title is automatically bound to the title of contentViewController. You can control the size of the window by using Auto Layout and applying size constraints to the view or its subviews. The initial size of the window is set to the initial size of contentView (that is, the size of contentViewController.view). The newly created window has releasedWhenClosed set to NOfalse, and it must be explicitly retained to keep the window instance alive.

    Availability

    Available in OS X v10.10 and later.

  • Initializes the window with the specified values.

    Declaration

    Swift

    init(contentRect contentRect: NSRect, styleMask aStyle: Int, backing bufferingType: NSBackingStoreType, defer flag: Bool)

    Objective-C

    - (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation

    Parameters

    contentRect

    Origin and size of the window’s content area in screen coordinates. Note that the window server limits window position coordinates to ±16,000 and sizes to 10,000.

    windowStyle

    The window’s style. It can be NSBorderlessWindowMask, or it can contain any of the options described in Window Style Masks, combined using the C bitwise OR operator. Borderless windows display none of the usual peripheral elements and are generally useful only for display or caching purposes; you should normally not need to create them. Also, note that a window’s style mask should include NSTitledWindowMask if it includes any of the others.

    bufferingType

    Specifies how the drawing done in the window is buffered by the window device, and possible values are described in NSBackingStoreType—Buffered Window Drawing.

    deferCreation

    Specifies whether the window server creates a window device for the window immediately. When YEStrue, the window server defers creating the window device until the window is moved onscreen. All display messages sent to the window or its views are postponed until the window is created, just before it’s moved onscreen.

    Return Value

    The initialized window.

    Discussion

    This method is the designated initializer for the NSWindow class.

    Deferring the creation of the window improves launch time and minimizes the virtual memory load on the window server.

    The new window creates a view to be its default content view. You can replace it with your own object by setting the contentView property.

    Availability

    Available in OS X v10.0 and later.

  • Initializes an allocated window with the specified values.

    Declaration

    Swift

    convenience init(contentRect contentRect: NSRect, styleMask aStyle: Int, backing bufferingType: NSBackingStoreType, defer flag: Bool, screen screen: NSScreen?)

    Objective-C

    - (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation screen:(NSScreen *)screen

    Parameters

    contentRect

    Origin and size of the window’s content area in screen coordinates. The origin is relative to the origin of the provided screen. Note that the window server limits window position coordinates to ±16,000 and sizes to 10,000.

    windowStyle

    The window’s style. It can be NSBorderlessWindowMask, or it can contain any of the options described in Window Style Masks, combined using the C bitwise OR operator. Borderless windows display none of the usual peripheral elements and are generally useful only for display or caching purposes; you should not usually need to create them. Also, note that a window’s style mask should include NSTitledWindowMask if it includes any of the others.

    bufferingType

    Specifies how the drawing done in the window is buffered by the window device; possible values are described in NSBackingStoreType—Buffered Window Drawing.

    deferCreation

    Specifies whether the window server creates a window device for the window immediately. When YEStrue, the window server defers creating the window device until the window is moved onscreen. All display messages sent to the window or its views are postponed until the window is created, just before it’s moved onscreen.

    screen

    Specifies the screen on which the window is positioned. The content rectangle is positioned relative to the bottom-left corner of screen. When nil, the content rectangle is positioned relative to (0, 0), which is the origin of the primary screen.

    Return Value

    The initialized window.

    Discussion

    The primary screen is the one that contains the current key window or, if there is no key window, the one that contains the main menu. If there’s neither a key window nor a main menu (if there’s no active application), the primary screen is the one where the origin of the screen coordinate system is located.

    Availability

    Available in OS X v10.0 and later.

  • The window’s style mask, indicating what kinds of control items it displays.

    Declaration

    Swift

    var styleMask: Int

    Objective-C

    @property NSUInteger styleMask

    Discussion

    For more information about style mask values, see Window Style Masks. The valid style mask values are the same values acceptable for use in initWithContentRect:styleMask:backing:defer:. Some style mask changes cause the view hierarchy to be rebuilt.

    Availability

    Available in OS X v10.0 and later.

  • Takes the window into or out of fullscreen mode,

    Declaration

    Swift

    func toggleFullScreen(_ sender: AnyObject?)

    Objective-C

    - (void)toggleFullScreen:(id)sender

    Parameters

    sender

    The object that sent the message.

    Discussion

    If an application supports fullscreen, it should add a menu item to the View menu with toggleFullScreen: as the action, and nil as the target.

    Availability

    Available in OS X v10.7 and later.

  • A Boolean value that indicates whether the window is able to receive keyboard and mouse events even when some other window is being run modally. (read-only)

    Declaration

    Swift

    var worksWhenModal: Bool { get }

    Objective-C

    @property(readonly) BOOL worksWhenModal

    Discussion

    The value of this property is YEStrue if the window is able to receive keyboard and mouse events even when some other window is being run modally; otherwise, NOfalse. By default, the NSWindow value of this property is NOfalse. Only subclasses of NSPanel should override this default.

    Availability

    Available in OS X v10.0 and later.

    See Also

    setWorksWhenModal: (NSPanel)

  • The window’s alpha value.

    Declaration

    Swift

    var alphaValue: CGFloat

    Objective-C

    @property CGFloat alphaValue

    Availability

    Available in OS X v10.0 and later.

  • The color of the window’s background.

    Declaration

    Swift

    @NSCopying var backgroundColor: NSColor!

    Objective-C

    @property(copy) NSColor *backgroundColor

    Availability

    Available in OS X v10.0 and later.

  • The window’s color space.

    Declaration

    Swift

    var colorSpace: NSColorSpace?

    Objective-C

    @property(strong) NSColorSpace *colorSpace

    Discussion

    The value of this property is nil if the window does not have a backing store, and is off-screen.

    Availability

    Available in OS X v10.6 and later.

  • The window’s content view, the highest accessible NSView object in the window’s view hierarchy.

    Declaration

    Swift

    var contentView: NSView?

    Objective-C

    @property(strong) __kindof NSView *contentView

    Discussion

    The window retains the new content view and owns it thereafter. The view object is resized to fit precisely within the content area of the window. You can modify the content view’s coordinate system through its bounds rectangle, but can’t alter its frame rectangle (that is, its size or location) directly.

    Setting this property causes the old content view to be released; if you plan to reuse it, be sure to retain it before changing the property value and to release it as appropriate when adding it to another NSWindow or NSView object.

    Availability

    Available in OS X v10.0 and later.

  • The main content view controller for the window.

    Declaration

    Swift

    var contentViewController: NSViewController?

    Objective-C

    @property(strong) NSViewController *contentViewController

    Discussion

    The value of this property provides the content view of the window. Setting this value removes the existing value of contentView and makes the contentViewController.view the main content view for the window. By default, the value of this property is nil.

    The content view controller controls only the contentView object, and not the title of the window. The window title can easily be bound to the contentViewController object using code such as: [window bind:NSTitleBinding toObject:contentViewController withKeyPath:@"title" options:nil]. Setting contentViewController causes the window to resize based on the current size of the contentViewController; to restrict the size of the window, use Auto Layout (note that the value of this property is encoded in the NIB). Directly assigning a contentView value clears out the root view controller.

    Availability

    Available in OS X v10.10 and later.

  • A Boolean value that indicates whether the window can be hidden when its application becomes hidden (during execution of the NSApplicationhide: method).

    Declaration

    Swift

    var canHide: Bool

    Objective-C

    @property BOOL canHide

    Discussion

    The value of this property is YEStrue if the window can be hidden when its application becomes hidden; otherwise, NOfalse. By default, the value of the property is YEStrue.

    Availability

    Available in OS X v10.0 and later.

  • Indicates whether the window can be visible on all spaces or on only one space at a time.

    Deprecation Statement

    Use collectionBehavior instead.

    Declaration

    Objective-C

    - (BOOL)canBeVisibleOnAllSpaces

    Return Value

    YEStrue when the window can be visible on all spaces; NOfalse when it can be visible on only one space at a time.

    Discussion

    The default is NOfalse.

    Availability

    Available in OS X v10.5 and later.

    Deprecated in OS X v10.5.

  • Specifies whether the window can be visible on all spaces or on only one space at a time.

    Deprecation Statement

    Use collectionBehavior instead.

    Declaration

    Objective-C

    - (void)setCanBeVisibleOnAllSpaces:(BOOL)flag

    Parameters

    flag

    YEStrue specifies that the window can be visible on all spaces; NOfalse specifies that the window can be visible on only one space at a time.

    Availability

    Available in OS X v10.5 and later.

    Deprecated in OS X v10.5.

  • A Boolean value that indicates whether the window is on the currently active space. (read-only)

    Declaration

    Swift

    var onActiveSpace: Bool { get }

    Objective-C

    @property(getter=isOnActiveSpace, readonly) BOOL onActiveSpace

    Discussion

    The value of this property is YEStrue if the window is on the currently active space; otherwise, NOfalse. For visible windows, this property indicates whether the window is currently visible on the active space. For nonvisible windows, it indicates whether ordering the window onscreen would cause it to be on the active space.

    Availability

    Available in OS X v10.6 and later.

  • A Boolean value that indicates whether the window is removed from the screen when its application becomes inactive.

    Declaration

    Swift

    var hidesOnDeactivate: Bool

    Objective-C

    @property BOOL hidesOnDeactivate

    Discussion

    The value of this property is YEStrue if the window is removed from the screen when its application is deactivated; NOfalse if it remains onscreen. The default value for NSWindow is NOfalse; the default value for NSPanel is YEStrue.

    Availability

    Available in OS X v10.0 and later.

  • A value that identifies the window’s behavior in window collections.

    Declaration

    Swift

    var collectionBehavior: NSWindowCollectionBehavior

    Objective-C

    @property NSWindowCollectionBehavior collectionBehavior

    Discussion

    The possible values for this property are listed in Managing Window Collections.

    Availability

    Available in OS X v10.5 and later.

  • A Boolean value that indicates whether the window is opaque.

    Declaration

    Swift

    var opaque: Bool

    Objective-C

    @property(getter=isOpaque) BOOL opaque

    Discussion

    The value of this property is YEStrue when the window is opaque; otherwise, NOfalse.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window has a shadow.

    Declaration

    Swift

    var hasShadow: Bool

    Objective-C

    @property BOOL hasShadow

    Discussion

    The value of this property is YEStrue when the window has a shadow; otherwise, NOfalse. If you change the value of this property, the window shadow is invalidated, forcing the window shadow to be recomputed.

    Availability

    Available in OS X v10.0 and later.

  • Invalidates the window shadow so that it is recomputed based on the current window shape.

    Declaration

    Swift

    func invalidateShadow()

    Objective-C

    - (void)invalidateShadow

    Availability

    Available in OS X v10.2 and later.

    See Also

    hasShadow

  • Indicates whether the window calculates the thickness of a given border automatically.

    Declaration

    Swift

    func autorecalculatesContentBorderThicknessForEdge(_ edge: NSRectEdge) -> Bool

    Objective-C

    - (BOOL)autorecalculatesContentBorderThicknessForEdge:(NSRectEdge)edge

    Parameters

    edge

    The border to check:

    • NSMaxYEdge: Top border.

    • NSMinYEdge: Bottom border.

    Return Value

    YEStrue when the window auto-recalculates the given border’s thickness; otherwise, NOfalse.

    Availability

    Available in OS X v10.5 and later.

  • Specifies whether the window calculates the thickness of a given border automatically.

    Declaration

    Swift

    func setAutorecalculatesContentBorderThickness(_ flag: Bool, forEdge edge: NSRectEdge)

    Objective-C

    - (void)setAutorecalculatesContentBorderThickness:(BOOL)autorecalculateContentBorderThickness forEdge:(NSRectEdge)edge

    Parameters

    autorecalculateContentBorderThickness

    If YEStrue, the window calculates the thickness of the edge automatically; if NOfalse, it does not.

    edge

    The border to set auto-recalculation on or off:

    • NSMaxYEdge: Top border.

    • NSMinYEdge: Bottom border.

    Special Considerations

    Turning off a border’s auto-recalculation status sets its border thickness to 0.0.

    In a nontextured window calling setAutorecalculatesContentBorderThickness:forEdge: passing NSMaxYEdge will raise an exception (in a nontextured window, it’s only valid to set the content border thickness of the bottom edge). It is only valid to set the content border thickness of the top edge in a textured window.

    Typically, if you call setContentBorderThickness:forEdge:, you should also call setAutorecalculatesContentBorderThickness:NO forEdge:.

    Availability

    Available in OS X v10.5 and later.

  • Indicates the thickness of a given border of the window.

    Declaration

    Swift

    func contentBorderThicknessForEdge(_ edge: NSRectEdge) -> CGFloat

    Objective-C

    - (CGFloat)contentBorderThicknessForEdge:(NSRectEdge)edge

    Parameters

    edge

    The border whose thickness to get:

    • NSMaxYEdge: Top border.

    • NSMinYEdge: Bottom border.

    Return Value

    Thickness of the given border, in points.

    Availability

    Available in OS X v10.5 and later.

  • Specifies the thickness of a given border of the window.

    Declaration

    Swift

    func setContentBorderThickness(_ thickness: CGFloat, forEdge edge: NSRectEdge)

    Objective-C

    - (void)setContentBorderThickness:(CGFloat)borderThickness forEdge:(NSRectEdge)edge

    Parameters

    borderThickness

    The thickness for edge, in points.

    edge

    The border whose thickness to set:

    • NSMaxYEdge: Top border.

    • NSMinYEdge: Bottom border.

    Discussion

    In a nontextured window calling setContentBorderThickness:forEdge: passing NSMaxYEdge will raise an exception (in a nontextured window, it’s only valid to set the content border thickness of the bottom edge). It is only valid to set the content border thickness of the top edge in a textured window.

    Typically, if you call setContentBorderThickness:forEdge:, you should also call setAutorecalculatesContentBorderThickness:NO forEdge:.

    The contentBorder does not include the title bar or toolbar, so a textured window that just wants the gradient in the title bar and toolbar should have a contentBorderThickness of 0 for NSMaxYEdge.

    Availability

    Available in OS X v10.5 and later.

  • The window’s delegate.

    Declaration

    Swift

    unowned(unsafe) var delegate: NSWindowDelegate?

    Objective-C

    @property(assign) id< NSWindowDelegate > delegate

    Discussion

    The value of this property is nil if the window doesn’t have a delegate.

    A window object’s delegate is inserted in the responder chain after the window itself and is informed of various actions by the window through delegation messages.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window prevents application termination when modal.

    Declaration

    Swift

    var preventsApplicationTerminationWhenModal: Bool

    Objective-C

    @property BOOL preventsApplicationTerminationWhenModal

    Discussion

    The value of this property is YEStrue if the window prevents application termination when modal; otherwise, NOfalse. The default value is YEStrue.

    Usually, application termination is prevented when a modal window or sheet is open, without consulting the application delegate. Some windows may wish not to prevent termination, however. Setting this property to NOfalse overrides the default behavior and allows termination to proceed even if the window is open, either through the sudden termination path if enabled, or after consulting the application delegate.

    Availability

    Available in OS X v10.6 and later.

  • The collection of drawers associated with the window. (read-only)

    Declaration

    Swift

    var drawers: [NSDrawer]? { get }

    Objective-C

    @property(readonly, copy) NSArray <NSDrawer *> *drawers

    Availability

    Available in OS X v10.0 and later.

  • The window’s window controller.

    Declaration

    Swift

    unowned(unsafe) var windowController: NSWindowController?

    Objective-C

    @property(assign) __kindof NSWindowController *windowController

    Availability

    Available in OS X v10.0 and later.

  • The sheet attached to the window. (read-only)

    Declaration

    Swift

    var attachedSheet: NSWindow? { get }

    Objective-C

    @property(readonly, strong) NSWindow *attachedSheet

    Discussion

    The value of this property is nil when the window doesn’t have a sheet attached.

    Availability

    Available in OS X v10.1 and later.

  • A Boolean value that indicates whether the window has ever run as a modal sheet. (read-only)

    Declaration

    Swift

    var sheet: Bool { get }

    Objective-C

    @property(getter=isSheet, readonly) BOOL sheet

    Discussion

    The value of this property is YEStrue if the window has ever run as a modal sheet; otherwise, NOfalse.

    Availability

    Available in OS X v10.1 and later.

  • Starts a document-modal session and presents—or queues for presentation—a sheet.

    Declaration

    Swift

    func beginSheet(_ sheetWindow: NSWindow, completionHandler handler: ((NSModalResponse) -> Void)?)

    Objective-C

    - (void)beginSheet:(NSWindow *)sheetWindow completionHandler:(void (^)(NSModalResponse returnCode))handler

    Parameters

    sheetWindow

    The window object that represents the sheet to present.

    handler

    The completion handler that gets called when the sheet’s modal session ends.

    Discussion

    If the window already has a presented sheet, this method queues the specified sheet for presentation after the current sheet is dismissed and then returns control to the caller.

    If the window has no presented sheets, this method displays the specified sheet, makes it key, and returns control to the caller. While the sheet remains visible, most events targeted at the receiver are prohibited. The runloop does not enter any special mode to accomplish this.

    Availability

    Available in OS X v10.9 and later.

  • Starts a document-modal session and presents the specified critical sheet.

    Declaration

    Swift

    func beginCriticalSheet(_ sheetWindow: NSWindow, completionHandler handler: ((NSModalResponse) -> Void)?)

    Objective-C

    - (void)beginCriticalSheet:(NSWindow *)sheetWindow completionHandler:(void (^)(NSModalResponse returnCode))handler

    Parameters

    sheetWindow

    The window object that represents the critical sheet to present. A critical sheet contains content that is time-critical or very important to the user.

    handler

    The completion handler that gets called when the sheet’s modal session ends.

    Discussion

    This method displays the sheet—on top of the window’s current sheet, if one exists—makes it key and returns control to the caller. While the sheet remains visible, most events targeted at the receiver are prohibited. The runloop does not enter any special mode to accomplish this.

    If the window already has a sheet when this method runs, the existing sheet is temporarily disabled while the critical sheet is presented. When the critical sheet is dismissed, the previously presented sheet continues its standard operation.

    Availability

    Available in OS X v10.9 and later.

  • Ends a document-modal session and dismisses the specified sheet.

    Declaration

    Swift

    func endSheet(_ sheetWindow: NSWindow)

    Objective-C

    - (void)endSheet:(NSWindow *)sheetWindow

    Parameters

    sheetWindow

    The window object that represents the sheet to be dismissed.

    Discussion

    This method ends the modal session with the return code NSModalResponseStop.

    Availability

    Available in OS X v10.9 and later.

  • Ends a document-modal session and dismisses the specified sheet.

    Declaration

    Swift

    func endSheet(_ sheetWindow: NSWindow, returnCode returnCode: NSModalResponse)

    Objective-C

    - (void)endSheet:(NSWindow *)sheetWindow returnCode:(NSModalResponse)returnCode

    Parameters

    sheetWindow

    The window object that represents the sheet to dismiss.

    returnCode

    The return code to send to the completion handler. You can use a custom value that you define or one of the return codes defined in the NSModalResponse enumeration or Additional NSModalResponse Values.

    Discussion

    This method ends the modal session with the specified return code.

    Availability

    Available in OS X v10.9 and later.

  • The window to which the sheet is attached. (read-only)

    Declaration

    Swift

    var sheetParent: NSWindow? { get }

    Objective-C

    @property(readonly, strong) NSWindow *sheetParent

    Discussion

    The value of this property is nil if the receiver is not a sheet or has no sheet parent.

    The window object in this property refers to the window to which the sheet is logically attached, regardless of appearance. The parent window–sheet relationship begins with the beginning of the sheet (for example, through beginSheet:completionHandler:) and ends with the sheet’s dismissal (for example, through endSheet:).

    Availability

    Available in OS X v10.9 and later.

  • An array of the sheets currently attached to the window. (read-only)

    Declaration

    Swift

    var sheets: [NSWindow] { get }

    Objective-C

    @property(readonly, copy) NSArray <__kindof NSWindow *> *sheets

    Discussion

    The value of this property is an ordered array that contains—in top-to-bottom order—the presented sheets that are attached to the window, followed by queued sheets, in the order they were queued. The array doesn’t include nested sheets or subsheets.

    Availability

    Available in OS X v10.9 and later.

  • The window’s frame rectangle in screen coordinates, including the title bar. (read-only)

    Declaration

    Swift

    var frame: NSRect { get }

    Objective-C

    @property(readonly) NSRect frame

    Availability

    Available in OS X v10.0 and later.

  • Positions the bottom-left corner of the window’s frame rectangle at a given point in screen coordinates.

    Declaration

    Swift

    func setFrameOrigin(_ aPoint: NSPoint)

    Objective-C

    - (void)setFrameOrigin:(NSPoint)point

    Parameters

    point

    The new position of the window’s bottom-left corner in screen coordinates.

    Discussion

    Note that the window server limits window position coordinates to ±16,000.

    Availability

    Available in OS X v10.0 and later.

  • Positions the top-left corner of the window’s frame rectangle at a given point in screen coordinates.

    Declaration

    Swift

    func setFrameTopLeftPoint(_ aPoint: NSPoint)

    Objective-C

    - (void)setFrameTopLeftPoint:(NSPoint)point

    Parameters

    point

    The new position of the window’s top-left corner in screen coordinates.

    Discussion

    Note that the window server limits window position coordinates to ±16,000; if necessary, adjust aPoint relative to the window’s lower-left corner to account for this limit.

    Availability

    Available in OS X v10.0 and later.

  • Modifies and returns a frame rectangle so that its top edge lies on a specific screen.

    Declaration

    Swift

    func constrainFrameRect(_ frameRect: NSRect, toScreen screen: NSScreen?) -> NSRect

    Objective-C

    - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen

    Parameters

    frameRect

    The proposed frame rectangle to adjust.

    screen

    The screen on which the top edge of the window’s frame is to lie.

    Return Value

    The adjusted frame rectangle.

    Discussion

    If the window is resizable and the window’s height is greater than the screen height, the rectangle’s height is adjusted to fit within the screen as well. The rectangle’s width and horizontal location are unaffected. You shouldn’t need to invoke this method yourself; it’s invoked automatically (and the modified frame is used to locate and set the size of the window) whenever a titled NSWindow object is placed onscreen and whenever its size is changed.

    Subclasses can override this method to prevent their instances from being constrained or to constrain them differently.

    Availability

    Available in OS X v10.0 and later.

  • Positions the window's top left to a given point.

    Declaration

    Swift

    func cascadeTopLeftFromPoint(_ topLeftPoint: NSPoint) -> NSPoint

    Objective-C

    - (NSPoint)cascadeTopLeftFromPoint:(NSPoint)topLeft

    Parameters

    topLeft

    The new top-left point, in screen coordinates, for the window. When NSZeroPoint, the window is not moved, except as needed to constrain to the visible screen

    Return Value

    The point shifted from top left of the window in screen coordinates.

    Discussion

    The returned point can be passed to a subsequent invocation of cascadeTopLeftFromPoint: to position the next window so the title bars of both windows are fully visible.

    Availability

    Available in OS X v10.0 and later.

  • Sets the origin and size of the window’s frame rectangle according to a given frame rectangle, thereby setting its position and size onscreen.

    Declaration

    Swift

    func setFrame(_ frameRect: NSRect, display flag: Bool)

    Objective-C

    - (void)setFrame:(NSRect)windowFrame display:(BOOL)displayViews

    Parameters

    windowFrame

    The frame rectangle for the window, including the title bar.

    displayViews

    Specifies whether the window redraws the views that need to be displayed. When YEStrue the window sends a displayIfNeeded message down its view hierarchy, thus redrawing all views.

    Discussion

    Note that the window server limits window position coordinates to ±16,000 and sizes to 10,000.

    Availability

    Available in OS X v10.0 and later.

  • Sets the origin and size of the window’s frame rectangle, with optional animation, according to a given frame rectangle, thereby setting its position and size onscreen.

    Declaration

    Swift

    func setFrame(_ frameRect: NSRect, display displayFlag: Bool, animate animateFlag: Bool)

    Objective-C

    - (void)setFrame:(NSRect)windowFrame display:(BOOL)displayViews animate:(BOOL)performAnimation

    Parameters

    windowFrame

    The frame rectangle for the window, including the title bar.

    displayViews

    Specifies whether the window redraws the views that need to be displayed. When YEStrue the window sends a displayIfNeeded message down its view hierarchy, thus redrawing all views.

    performAnimation

    Specifies whether the window performs a smooth resize. YEStrue to perform the animation, whose duration is specified by animationResizeTime:.

    Availability

    Available in OS X v10.0 and later.

  • Specifies the duration of a smooth frame-size change.

    Declaration

    Swift

    func animationResizeTime(_ newFrame: NSRect) -> NSTimeInterval

    Objective-C

    - (NSTimeInterval)animationResizeTime:(NSRect)newWindowFrame

    Parameters

    newWindowFrame

    The frame rectangle specified in setFrame:display:animate:.

    Return Value

    The duration of the frame size change.

    Discussion

    Subclasses can override this method to control the total time for the frame change.

    The NSWindow implementation uses the value from the NSWindowResizeTime user default as the time in seconds to resize by 150 pixels. If this value is unspecified, NSWindowResizeTime is 0.20 seconds (this default value may be different in different releases of OS X).

    Availability

    Available in OS X v10.0 and later.

  • The window’s aspect ratio, which constrains the size of its frame rectangle to integral multiples of this ratio when the user resizes it.

    Declaration

    Swift

    var aspectRatio: NSSize

    Objective-C

    @property NSSize aspectRatio

    Discussion

    The size of the window’s frame rectangle is constrained to integral multiples of this ratio when the user resizes it. You can set an NSWindow object’s size to any ratio programmatically.

    An NSWindow object’s aspect ratio and its resize increments are mutually exclusive attributes. In fact, setting one attribute cancels the setting of the other. For example, to cancel an established aspect ratio setting for an NSWindow object, you can set the resizeIncrements property with the width and height set to 1.0:

    1. myWindow.resizeIncrements = NSMakeSize(1.0,1.0);

    The contentAspectRatio property takes precedence over this property.

    Availability

    Available in OS X v10.0 and later.

  • The minimum size to which the window’s frame (including its title bar) can be sized.

    Declaration

    Swift

    var minSize: NSSize

    Objective-C

    @property NSSize minSize

    Discussion

    The minimum size constraint is enforced for resizing by the user as well as for the setFrame... methods other than setFrame:display: and setFrame:display:animate:.

    The setContentMinSize: method takes precedence over this property.

    Availability

    Available in OS X v10.0 and later.

  • The maximum size to which the window’s frame (including its title bar) can be sized.

    Declaration

    Swift

    var maxSize: NSSize

    Objective-C

    @property NSSize maxSize

    Discussion

    The maximum size constraint is enforced for resizing by the user as well as for the setFrame... methods other than setFrame:display: and setFrame:display:animate:. Note that the window server limits window sizes to 10,000.

    The default maximum size of a window is {FLT_MAX, FLT_MAX} (FLT_MAX is defined in /usr/include/float.h). When the maximum size of a window has been set, there is no way to reset it other than by specifying this default maximum size.

    The contentMaxSize property takes precedence over this property.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window is in a zoomed state. (read-only)

    Declaration

    Swift

    var zoomed: Bool { get }

    Objective-C

    @property(getter=isZoomed, readonly) BOOL zoomed

    Discussion

    The value of this property is YEStrue if the window is in a zoomed state; otherwise, NOfalse.

    The zoomed state of the window is determined using the following steps:

    1. If the delegate or the window class implements windowWillUseStandardFrame:defaultFrame:, it is invoked to obtain the zoomed frame of the window. The value of zoomed is then determined by whether or not the current window frame is equal to the zoomed frame.

    2. If the neither the delegate nor the window class implements windowWillUseStandardFrame:defaultFrame:, a default frame that nearly fits the screen is chosen. If the delegate or window class implements windowWillUseStandardFrame:defaultFrame:, it is invoked to validate the proposed zoomed frame. After the zoomed frame is validated, the value of zoomed is determined by whether or not the current window frame is equal to the zoomed frame.

    Availability

    Available in OS X v10.0 and later.

    See Also

    – zoom:

  • This action method simulates the user clicking the zoom box by momentarily highlighting the button and then zooming the window.

    Declaration

    Swift

    func performZoom(_ sender: AnyObject?)

    Objective-C

    - (void)performZoom:(id)sender

    Parameters

    sender

    The object sending the message.

    Discussion

    If the window doesn’t have a zoom box or can’t be zoomed for some reason, the computer beeps.

    Availability

    Available in OS X v10.0 and later.

  • This action method toggles the size and location of the window between its standard state (provided by the application as the “best” size to display the window’s data) and its user state (a new size and location the user may have set by moving or resizing the window).

    Declaration

    Swift

    func zoom(_ sender: AnyObject?)

    Objective-C

    - (void)zoom:(id)sender

    Parameters

    sender

    The object sending the message.

    Discussion

    For more information on the standard and user states, see windowWillUseStandardFrame:defaultFrame:.

    The zoom: method is typically invoked after a user clicks the window’s zoom box but may also be invoked programmatically from the performZoom: method. It performs the following steps:

    1. Invokes the windowWillUseStandardFrame:defaultFrame: method, if the delegate or the window class implements it, to obtain a “best fit” frame for the window. If neither the delegate nor the window class implements the method, uses a default frame that nearly fills the current screen, which is defined to be the screen containing the largest part of the window’s current frame.

    2. Adjusts the resulting frame, if necessary, to fit on the current screen.

    3. Compares the resulting frame to the current frame to determine whether the window’s standard frame is currently displayed. If the current frame is within a few pixels of the standard frame in size and location, it is considered a match.

    4. Determines a new frame. If the window is currently in the standard state, the new frame represents the user state, saved during a previous zoom. If the window is currently in the user state, the new frame represents the standard state, computed in step 1 above. If there is no saved user state because there has been no previous zoom, the size and location of the window do not change.

    5. Determines whether the window currently allows zooming. By default, zooming is allowed. If the window’s delegate implements the windowShouldZoom:toFrame: method, zoom: invokes that method. If the delegate doesn’t implement the method but the window does, zoom: invokes the window’s version. windowShouldZoom:toFrame: returns NOfalse if zooming is not currently allowed.

    6. If the window currently allows zooming, sets the new frame.

    Availability

    Available in OS X v10.0 and later.

    See Also

    zoomed

  • The flags field of the event record for the mouse-down event that initiated the resizing session. (read-only)

    Declaration

    Swift

    var resizeFlags: Int { get }

    Objective-C

    @property(readonly) NSInteger resizeFlags

    Discussion

    The value of this property is a mask indicating which of the modifier keys was held down when the mouse-down event occurred. The flags are listed in NSEvent object’s modifierFlags method description. The property is valid only while the window is being resized.

    You can used this property to constrain the direction or amount of resizing. Because of its limited validity, this property should only be accessed from within an implementation of the delegate method windowWillResize:toSize:.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window’s resize indicator is visible.

    Declaration

    Swift

    var showsResizeIndicator: Bool

    Objective-C

    @property BOOL showsResizeIndicator

    Discussion

    The value of this property is YEStrue when the window’s resize indicator is visible; otherwise, NOfalse. This property does not affect whether the window is resizable.

    Availability

    Available in OS X v10.0 and later.

  • The window’s resizing increments.

    Declaration

    Swift

    var resizeIncrements: NSSize

    Objective-C

    @property NSSize resizeIncrements

    Discussion

    This property restricts the user’s ability to resize the window so the width and height change by multiples of width and height increments. As the user resizes the window, its size changes by multiples of increments.width and increments.height, which should be whole numbers, 1.0 or greater. Whatever the current resizing increments, you can set an NSWindow object’s size to any height and width programmatically.

    Resize increments and aspect ratio are mutually exclusive attributes. For more information, see aspectRatio.

    The contentResizeIncrements property takes precedence over this property.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window tries to optimize user-initiated resize operations by preserving the content of views that have not changed.

    Declaration

    Swift

    var preservesContentDuringLiveResize: Bool

    Objective-C

    @property BOOL preservesContentDuringLiveResize

    Discussion

    The value of this property is YEStrue if the window tries to optimize live resize operations by preserving the content of views that have not moved; otherwise, NOfalse. By default, live-resize optimization is turned on.

    When live-resize optimization is active, the window redraws only those views that moved (or do not support this optimization) during a live resize operation. You might consider disabling this optimization for the window if none of the window’s contained views can take advantage of it. Disabling the optimization for the window prevents it from checking each view to see if the optimization is supported.

    See preservesContentDuringLiveResize in NSView for additional information on how to support this optimization.

    Availability

    Available in OS X v10.4 and later.

  • A Boolean value that indicates whether the window is being resized by the user. (read-only)

    Declaration

    Swift

    var inLiveResize: Bool { get }

    Objective-C

    @property(readonly) BOOL inLiveResize

    Discussion

    The value of this property is YEStrue if the window is being live resized; otherwise, NOfalse.

    Availability

    Available in OS X v10.6 and later.

  • The window’s content aspect ratio.

    Declaration

    Swift

    var contentAspectRatio: NSSize

    Objective-C

    @property NSSize contentAspectRatio

    Discussion

    By default, the content aspect ratio (that is, height in relation to width) is (0, 0). If you set the aspect ratio of a window’s content view, the dimensions of its content rectangle are constrained to integral multiples of that ratio when users resize it. You can set a window’s content view to any size programmatically, regardless of its aspect ratio. The value of this property takes precedence over aspectRatio.

    Availability

    Available in OS X v10.3 and later.

  • The minimum size of the window’s content view in the window’s base coordinate system.

    Declaration

    Swift

    var contentMinSize: NSSize

    Objective-C

    @property NSSize contentMinSize

    Discussion

    The minimum size constraint is enforced for resizing by the user as well as for the setContentSize: method and the setFrame... methods other than setFrame:display: and setFrame:display:animate:. This method takes precedence over the minSize property.

    Availability

    Available in OS X v10.3 and later.

    See Also

    contentMaxSize

  • Sets the size of the window’s content view to a given size, which is expressed in the window’s base coordinate system.

    Declaration

    Swift

    func setContentSize(_ aSize: NSSize)

    Objective-C

    - (void)setContentSize:(NSSize)size

    Parameters

    size

    The new size of the window’s content view in the window’s base coordinate system.

    Discussion

    This size in turn alters the size of the NSWindow object itself. Note that the window server limits window sizes to 10,000; if necessary, be sure to limit aSize relative to the frame rectangle.

    Availability

    Available in OS X v10.0 and later.

  • The maximum size of the window’s content view in the window’s base coordinate system.

    Declaration

    Swift

    var contentMaxSize: NSSize

    Objective-C

    @property NSSize contentMaxSize

    Discussion

    The maximum size constraint is enforced for resizing by the user as well as for the setContentSize: method and the setFrame... methods other than setFrame:display: and setFrame:display:animate:. This method takes precedence over the maxSize property.

    Availability

    Available in OS X v10.3 and later.

  • The window’s content-view resizing increments.

    Declaration

    Swift

    var contentResizeIncrements: NSSize

    Objective-C

    @property NSSize contentResizeIncrements

    Discussion

    The value of this property restricts the user’s ability to resize the window so the width and height of its content view change by multiples of width and height increments. As the user resizes the window, the size of its content view changes by integral multiples of contentResizeIncrements.width and contentResizeIncrements.height. However, you can set a window’s size to any width and height programmatically. This property takes precedence over resizeIncrements.

    Availability

    Available in OS X v10.3 and later.

  • A value used by Auto Layout constraints to automatically bind to the value of contentLayoutRect. (read-only)

    Declaration

    Swift

    var contentLayoutGuide: AnyObject? { get }

    Objective-C

    @property(readonly) id contentLayoutGuide

    Availability

    Available in OS X v10.10 and later.

  • The area inside the window that is for non-obscured content, in window coordinates. (read-only)

    Declaration

    Swift

    var contentLayoutRect: NSRect { get }

    Objective-C

    @property(readonly) NSRect contentLayoutRect

    Discussion

    Typically, the area represented by this property is the same as the frame of the contentView. However, for windows with NSFullSizeContentViewWindowMask set, there needs to be a way to determine the portion that is not under the toolbar. The contentLayoutRect property contains the portion of the layout that is not obscured under the toolbar. This property is KVO compliant.

    Availability

    Available in OS X v10.10 and later.

  • A maximum size that is used to determine if a window can fit when it is in full screen in a tile.

    Declaration

    Swift

    var maxFullScreenContentSize: NSSize

    Objective-C

    @property NSSize maxFullScreenContentSize

    Discussion

    By default, the system uses Auto Layout to determine the maximum size, so applications that don’t change window content upon entering full screen should not need to set the value of maxFullScreenContentSize. (If Auto Layout is not used, the system queries contentMinSize and contentMaxSize.) If an application does significant rework of the user interface in full screen, then it may be necessary to set the value of maxFullScreenContentSize. You can use this property even if the window does not support full screen, but can be implicitly opted into supporting a full screen tile based on resizing behavior and window properties (for more information, see the collectionBehavior property).

    Availability

    Available in OS X v10.11 and later.

  • A minimum size that is used to determine if a window can fit when it is in full screen in a tile.

    Declaration

    Swift

    var minFullScreenContentSize: NSSize

    Objective-C

    @property NSSize minFullScreenContentSize

    Discussion

    By default, the system uses Auto Layout to determine the minimum size, so applications that don’t change window content upon entering full screen should not need to set the value of minFullScreenContentSize. (If Auto Layout is not used, the system queries contentMinSize and contentMaxSize.) If an application does significant rework of the user interface in full screen, then it may be necessary to set the value of minFullScreenContentSize. You can use this property even if the window does not support full screen, but can be implicitly opted into supporting a full screen tile based on resizing behavior and window properties (for more information, see the collectionBehavior property).

    Availability

    Available in OS X v10.11 and later.

  • Removes the window from the screen list, which hides the window.

    Declaration

    Swift

    func orderOut(_ sender: AnyObject?)

    Objective-C

    - (void)orderOut:(id)sender

    Parameters

    sender

    The message’s sender.

    Discussion

    If the window is the key or main window, the NSWindow object immediately behind it is made key or main in its place. Calling the orderOut: method causes the window to be removed from the screen, but does not cause it to be released. See the close method for information on when a window is released.

    The default animation based on the window type will be used when the window is ordered out unless it has been modified by the animationBehavior property.

    Availability

    Available in OS X v10.0 and later.

  • Moves the window to the back of its level in the screen list, without changing either the key window or the main window.

    Declaration

    Swift

    func orderBack(_ sender: AnyObject?)

    Objective-C

    - (void)orderBack:(id)sender

    Parameters

    sender

    Message originator.

    Availability

    Available in OS X v10.0 and later.

  • Moves the window to the front of its level in the screen list, without changing either the key window or the main window.

    Declaration

    Swift

    func orderFront(_ sender: AnyObject?)

    Objective-C

    - (void)orderFront:(id)sender

    Parameters

    sender

    The message’s sender.

    Discussion

    The default animation based on the window type will be used when the window is ordered front unless it has been modified by the animationBehavior property.

    Availability

    Available in OS X v10.0 and later.

  • Moves the window to the front of its level, even if its application isn’t active, without changing either the key window or the main window.

    Declaration

    Swift

    func orderFrontRegardless()

    Objective-C

    - (void)orderFrontRegardless

    Parameters

    sender

    The message’s sender.

    Discussion

    Normally an NSWindow object can’t be moved in front of the key window unless it and the key window are in the same application. You should rarely need to invoke this method; it’s designed to be used when applications are cooperating in such a way that an active application (with the key window) is using another application to display data.

    Availability

    Available in OS X v10.0 and later.

  • Repositions the window’s window device in the window server’s screen list.

    Declaration

    Swift

    func orderWindow(_ place: NSWindowOrderingMode, relativeTo otherWin: Int)

    Objective-C

    - (void)orderWindow:(NSWindowOrderingMode)orderingMode relativeTo:(NSInteger)otherWindowNumber

    Parameters

    orderingMode
    • NSWindowOut: The window is removed from the screen list and otherWindowNumber is ignored.

    • NSWindowAbove: The window is ordered immediately in front of the window whose window number is otherWindowNumber

    • NSWindowBelow: The window is placed immediately behind the window represented by otherWindowNumber.

    otherWindowNumber

    The number of the window the window is to be placed in front of or behind. Pass 0 to place the window in front of (when orderingMode is NSWindowAbove) or behind (when orderingMode is NSWindowBelow) all other windows in its level.

    Availability

    Available in OS X v10.0 and later.

  • The window level of the window.

    Declaration

    Swift

    var level: Int

    Objective-C

    @property NSInteger level

    Discussion

    See Window Levels for a list of possible values. Each level in the list groups windows within it in front of those in all preceding groups. Floating windows, for example, appear in front of all normal-level windows. When a window enters a new level, it’s ordered in front of all its peers in that level.

    The constant NSTornOffMenuWindowLevel is preferable to its synonym, NSSubmenuWindowLevel.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window is visible onscreen (even when it’s obscured by other windows). (read-only)

    Declaration

    Swift

    var visible: Bool { get }

    Objective-C

    @property(getter=isVisible, readonly) BOOL visible

    Discussion

    The value of this property is YEStrue when the window is onscreen (even if it’s obscured by other windows); otherwise, NOfalse.

    Availability

    Available in OS X v10.0 and later.

    See Also

    visibleRect (NSView)

  • The occlusion state of the window. (read-only)

    Declaration

    Swift

    var occlusionState: NSWindowOcclusionState { get }

    Objective-C

    @property(readonly) NSWindowOcclusionState occlusionState

    Discussion

    When the value of this property is NSWindowOcclusionStateVisible, at least part of the window is visible; otherwise, the window is fully occluded.

    Availability

    Available in OS X v10.9 and later.

  • Removes the frame data stored under a given name from the application’s user defaults.

    Declaration

    Swift

    class func removeFrameUsingName(_ name: String)

    Objective-C

    + (void)removeFrameUsingName:(NSString *)frameName

    Parameters

    frameName

    The name of the frame to remove.

    Availability

    Available in OS X v10.0 and later.

  • Sets the window’s frame rectangle by reading the rectangle data stored under a given name from the defaults system.

    Declaration

    Swift

    func setFrameUsingName(_ name: String) -> Bool

    Objective-C

    - (BOOL)setFrameUsingName:(NSString *)frameName

    Parameters

    frameName

    The name of the frame to read.

    Return Value

    YEStrue when frameName is read and the frame is set successfully; otherwise, NOfalse.

    Discussion

    The frame is constrained according to the window’s minimum and maximum size settings. This method causes a windowWillResize:toSize: message to be sent to the delegate.

    Availability

    Available in OS X v10.0 and later.

  • Sets the window’s frame rectangle by reading the rectangle data stored under a given name from the defaults system. Can operate on non-resizable windows.

    Declaration

    Swift

    func setFrameUsingName(_ name: String, force force: Bool) -> Bool

    Objective-C

    - (BOOL)setFrameUsingName:(NSString *)frameName force:(BOOL)force

    Parameters

    frameName

    The name of the frame to read.

    force

    YEStrue to use setFrameUsingName: on a non-resizable window; NOfalse to fail on a non-resizable window.

    Return Value

    YEStrue when frameName is read and the frame is set successfully; otherwise,NOfalse.

    Availability

    Available in OS X v10.0 and later.

  • Saves the window’s frame rectangle in the user defaults system under a given name.

    Declaration

    Swift

    func saveFrameUsingName(_ name: String)

    Objective-C

    - (void)saveFrameUsingName:(NSString *)frameName

    Parameters

    frameName

    The name under which the frame is to be saved.

    Discussion

    With the companion method setFrameUsingName:, you can save and reset an NSWindow object’s frame over various launches of an application. The default is owned by the application and stored under the name "NSWindow Frame frameName". See NSUserDefaults for more information.

    Availability

    Available in OS X v10.0 and later.

  • The name used to automatically save the window’s frame rectangle data in the defaults system. (read-only)

    Declaration

    Swift

    var frameAutosaveName: String { get }

    Objective-C

    @property(readonly, copy) NSString *frameAutosaveName

    Discussion

    The value of this property is YEStrue when the frame name is set successfully; NOfalse when the value is being used as an autosave name by another NSWindow object in the application (in which case the window’s old name remains in effect).

    Availability

    Available in OS X v10.0 and later.

  • A string representation of the window’s frame rectangle. (read-only)

    Declaration

    Swift

    var stringWithSavedFrame: String { get }

    Objective-C

    @property(readonly, copy) NSString *stringWithSavedFrame

    Discussion

    The value of this property is a string that can be used in a later call to setFrameFromString:.

    Availability

    Available in OS X v10.0 and later.

  • Sets the window’s frame rectangle from a given string representation.

    Declaration

    Swift

    func setFrameFromString(_ string: String)

    Objective-C

    - (void)setFrameFromString:(NSString *)frameString

    Parameters

    frameString

    A string representation of a frame rectangle, previously accessed using stringWithSavedFrame.

    Discussion

    If the window is not resizable, this method will not resize the window. The frame is constrained according to the window’s minimum and maximum size settings. This method causes a windowWillResize:toSize: message to be sent to the delegate.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window is the application’s main window. (read-only)

    Declaration

    Swift

    var mainWindow: Bool { get }

    Objective-C

    @property(getter=isMainWindow, readonly) BOOL mainWindow

    Discussion

    The value of this property is YEStrue when the window is the main window for the application; otherwise, NOfalse.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window can become the application’s main window. (read-only)

    Declaration

    Swift

    var canBecomeMainWindow: Bool { get }

    Objective-C

    @property(readonly) BOOL canBecomeMainWindow

    Discussion

    The value of this property is YEStrue when the window can become the main window; otherwise, NOfalse.

    Attempts to make the window the main window are abandoned if the value of this property is NOfalse. The value of the property is YEStrue if the window is visible, is not an NSPanel object, and has a title bar or a resize mechanism. Otherwise, the value is NOfalse.

    Availability

    Available in OS X v10.0 and later.

  • Makes the window the main window.

    Declaration

    Swift

    func makeMainWindow()

    Objective-C

    - (void)makeMainWindow

    Availability

    Available in OS X v10.0 and later.

  • Invoked automatically to inform the window that it has become the main window; never invoke this method directly.

    Declaration

    Swift

    func becomeMainWindow()

    Objective-C

    - (void)becomeMainWindow

    Discussion

    This method posts an NSWindowDidBecomeMainNotification to the default notification center.

    Availability

    Available in OS X v10.0 and later.

  • Invoked automatically when the window resigns main window status; never invoke this method directly.

    Declaration

    Swift

    func resignMainWindow()

    Objective-C

    - (void)resignMainWindow

    Discussion

    This method sends windowDidResignMain: to the window’s delegate and posts an NSWindowDidResignMainNotification to the default notification center.

    Availability

    Available in OS X v10.0 and later.

  • The window’s toolbar.

    Declaration

    Swift

    var toolbar: NSToolbar?

    Objective-C

    @property(strong) NSToolbar *toolbar

    Discussion

    For more information about toolbars, see NSToolbar Class Reference.

    Availability

    Available in OS X v10.0 and later.

  • The action method for the “Hide Toolbar” menu item (which alternates with “Show Toolbar”).

    Declaration

    Swift

    func toggleToolbarShown(_ sender: AnyObject?)

    Objective-C

    - (void)toggleToolbarShown:(id)sender

    Parameters

    sender

    The message’s sender.

    Discussion

    See the NSToolbar class description for additional information.

    Availability

    Available in OS X v10.0 and later.

  • The action method for the “Customize Toolbar…” menu item.

    Declaration

    Swift

    func runToolbarCustomizationPalette(_ sender: AnyObject?)

    Objective-C

    - (void)runToolbarCustomizationPalette:(id)sender

    Parameters

    sender

    The message’s sender.

    Discussion

    See the NSToolbar class description for additional information.

    Availability

    Available in OS X v10.0 and later.

  • An array of the window’s attached child windows. (read-only)

    Declaration

    Swift

    var childWindows: [NSWindow]? { get }

    Objective-C

    @property(readonly, copy) NSArray <__kindof NSWindow *> *childWindows

    Availability

    Available in OS X v10.2 and later.

  • Adds a given window as a child window of the window.

    Declaration

    Swift

    func addChildWindow(_ childWin: NSWindow, ordered place: NSWindowOrderingMode)

    Objective-C

    - (void)addChildWindow:(NSWindow *)childWindow ordered:(NSWindowOrderingMode)orderingMode

    Parameters

    childWindow

    The child window to order.

    orderingMode
    • NSWindowAbove: childWindow is ordered immediately in front of the window.

    • NSWindowBelow: childWindow is ordered immediately behind the window.

    Discussion

    After the childWindow is added as a child of the window, it is maintained in relative position indicated by orderingMode for subsequent ordering operations involving either window. While this attachment is active, moving childWindow will not cause the window to move (as in sliding a drawer in or out), but moving the window will cause childWindow to move.

    Note that you should not create cycles between parent and child windows. For example, you should not add window B as child of window A, then add window A as a child of window B.

    Availability

    Available in OS X v10.2 and later.

  • Detaches a given child window from the window.

    Declaration

    Swift

    func removeChildWindow(_ childWin: NSWindow)

    Objective-C

    - (void)removeChildWindow:(NSWindow *)childWindow

    Parameters

    childWindow

    The child window to detach.

    Availability

    Available in OS X v10.2 and later.

  • The parent window to which the window is attached as a child.

    Declaration

    Swift

    unowned(unsafe) var parentWindow: NSWindow?

    Objective-C

    @property(assign) NSWindow *parentWindow

    Discussion

    This property should be set from a subclass when it is overridden by a subclass’s implementation. It should not be set otherwise.

    Availability

    Available in OS X v10.2 and later.

  • A Boolean value that indicates whether the window’s flushing ability is disabled. (read-only)

    Declaration

    Swift

    var flushWindowDisabled: Bool { get }

    Objective-C

    @property(getter=isFlushWindowDisabled, readonly) BOOL flushWindowDisabled

    Discussion

    The value of this property is YEStrue when the window’s flushing ability has been disabled; otherwise, NOfalse.

    Availability

    Available in OS X v10.0 and later.

  • Reenables the flushWindow method for the window after it was disabled through a previous disableFlushWindow message.

    Declaration

    Swift

    func enableFlushWindow()

    Objective-C

    - (void)enableFlushWindow

    Availability

    Available in OS X v10.0 and later.

  • Disables the flushWindow method for the window.

    Declaration

    Swift

    func disableFlushWindow()

    Objective-C

    - (void)disableFlushWindow

    Discussion

    If the window is buffered, disabling flushWindow prevents drawing from being automatically flushed by the NSView display... methods from the window’s backing store to the screen. This method permits several views to be drawn before the results are shown to the user.

    Flushing should be disabled only temporarily, while the window’s display is being updated. Each disableFlushWindow message must be paired with a subsequent enableFlushWindow message. Invocations of these methods can be nested; flushing isn’t reenabled until the last enableFlushWindow message is sent.

    Availability

    Available in OS X v10.0 and later.

  • Flushes the window’s offscreen buffer to the screen if the window is buffered and flushing is enabled.

    Declaration

    Swift

    func flushWindow()

    Objective-C

    - (void)flushWindow

    Discussion

    Does nothing for other display devices, such as a printer. This method is automatically invoked by the NSWindow display and displayIfNeeded methods and the corresponding NSView display and displayIfNeeded methods.

    Availability

    Available in OS X v10.0 and later.

  • Flushes the window’s offscreen buffer to the screen if flushing is enabled and if the last flushWindow message had no effect because flushing was disabled.

    Declaration

    Swift

    func flushWindowIfNeeded()

    Objective-C

    - (void)flushWindowIfNeeded

    Discussion

    To avoid unnecessary flushing, use this method rather than flushWindow to flush an NSWindow object after flushing has been reenabled.

    Availability

    Available in OS X v10.0 and later.

  • Returns the window’s field editor, creating it if requested.

    Declaration

    Swift

    func fieldEditor(_ createFlag: Bool, forObject anObject: AnyObject?) -> NSText?

    Objective-C

    - (NSText *)fieldEditor:(BOOL)createWhenNeeded forObject:(id)anObject

    Parameters

    createWhenNeeded

    If YEStrue, creates a field editor if one doesn’t exist; if NOfalse, does not create a field editor.

    A freshly created NSWindow object doesn’t have a field editor. After a field editor has been created for a window, the createWhenNeeded argument is ignored. By passing NOfalse for createWhenNeeded and testing the return value, however, you can predicate an action on the existence of the field editor.

    anObject

    A text-displaying object for which the delegate (in windowWillReturnFieldEditor:toObject:) assigns a custom field editor. Pass nil to get the default field editor, which can be the NSWindow field editor or a custom field editor returned by the delegate.

    Return Value

    Returns the field editor for the designated object (anObject) or, if anObject is nil, the default field editor. Returns nil if createFlag is NOfalse and if the field editor doesn’t exist.

    Discussion

    The field editor is a single NSTextView object that is shared among all the controls in a window for light text-editing needs. It is automatically instantiated when needed, and it can be used however your application sees fit. Typically, the field editor is used by simple text-bearing objects—for example, an NSTextField object uses its window’s field editor to display and manipulate text. The field editor can be shared by any number of objects, and so its state may be constantly changing. Therefore, it shouldn’t be used to display text that demands sophisticated layout (for this you should create a dedicated NSTextView object).

    The field editor may be in use by some view object, so be sure to properly dissociate it from that object before actually using it yourself (the appropriate way to do this is illustrated in the description of endEditingFor:). Once you retrieve the field editor, you can insert it in the view hierarchy, set a delegate to interpret text events, and have it perform whatever editing is needed. Then, when it sends a textDidEndEditing: message to the delegate, you can get its text to display or store and remove the field editor using endEditingFor:.

    The window’s delegate can substitute a custom field editor in place of the window’s field editor by implementing windowWillReturnFieldEditor:toObject:. The custom field editor can become the default editor (common to all text-displaying objects) or specific to a particular text-displaying object (anObject). The window sends this message to its delegate with itself and anObject as the arguments; if the delegate returns a non-nil value, the window returns that object instead of its field editor in fieldEditor:forObject:. However, note the following:

    • If the window’s delegate is identical to anObject, windowWillReturnFieldEditor:toObject: isn’t sent to the delegate.

    • The object returned by the delegate method, though it may become first responder, does not become the window's default field editor. Other objects continue to use the window's default field editor.

    Availability

    Available in OS X v10.0 and later.

  • Forces the field editor to give up its first responder status and prepares it for its next assignment.

    Declaration

    Swift

    func endEditingFor(_ anObject: AnyObject?)

    Objective-C

    - (void)endEditingFor:(id)object

    Parameters

    object

    The object that is using the window’s field editor.

    Discussion

    If the field editor is the first responder, it’s made to resign that status even if its resignFirstResponder method returns NOfalse. This registration forces the field editor to send a textDidEndEditing: message to its delegate. The field editor is then removed from the view hierarchy, its delegate is set to nil, and it’s emptied of any text it may contain.

    This method is typically invoked by the object using the field editor when it’s finished. Other objects normally change the first responder by simply using makeFirstResponder:, which allows a field editor or other object to retain its first responder status if, for example, the user has entered an invalid value. The endEditingFor: method should be used only as a last resort if the field editor refuses to resign first responder status. Even in this case, you should always allow the field editor a chance to validate its text and take whatever other action it needs first. You can do this by first trying to make the NSWindow object the first responder:

    1. if ([myWindow makeFirstResponder:myWindow]) {
    2. /* All fields are now valid; its safe to use fieldEditor:forObject:
    3. to claim the field editor. */
    4. }
    5. else {
    6. /* Force first responder to resign. */
    7. [myWindow endEditingFor:nil];
    8. }

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window is excluded from the application’s Windows menu.

    Declaration

    Swift

    var excludedFromWindowsMenu: Bool

    Objective-C

    @property(getter=isExcludedFromWindowsMenu) BOOL excludedFromWindowsMenu

    Discussion

    The value of this property is YEStrue when the window is excluded from the Windows menu; otherwise, NOfalse. The default initial setting is NOfalse.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window’s cursor rectangles are enabled. (read-only)

    Declaration

    Swift

    var areCursorRectsEnabled: Bool { get }

    Objective-C

    @property(readonly) BOOL areCursorRectsEnabled

    Discussion

    The value of this property is YEStrue when cursor rectangles are enabled; otherwise, NOfalse.

    Availability

    Available in OS X v10.0 and later.

  • Reenables cursor rectangle management within the window after a disableCursorRects message.

    Declaration

    Swift

    func enableCursorRects()

    Objective-C

    - (void)enableCursorRects

    Availability

    Available in OS X v10.0 and later.

  • Disables all cursor rectangle management within the window.

    Declaration

    Swift

    func disableCursorRects()

    Objective-C

    - (void)disableCursorRects

    Discussion

    Use this method when you need to do some special cursor manipulation and you don’t want the Application Kit interfering.

    Availability

    Available in OS X v10.0 and later.

  • Invalidates all cursor rectangles in the window.

    Declaration

    Swift

    func discardCursorRects()

    Objective-C

    - (void)discardCursorRects

    Discussion

    This method is invoked by resetCursorRects to clear out existing cursor rectangles before resetting them. You shouldn’t invoke it in the code you write, but you might want to override it to change its behavior.

    Availability

    Available in OS X v10.0 and later.

  • Marks as invalid the cursor rectangles of a given NSView object in the window’s view hierarchy, so they’ll be set up again when the window becomes key (or immediately if the window is key).

    Declaration

    Swift

    func invalidateCursorRectsForView(_ aView: NSView)

    Objective-C

    - (void)invalidateCursorRectsForView:(NSView *)view

    Parameters

    view

    The view in the window’s view hierarchy.

    Availability

    Available in OS X v10.0 and later.

  • Clears the window’s cursor rectangles and the cursor rectangles of the NSView objects in its view hierarchy.

    Declaration

    Swift

    func resetCursorRects()

    Objective-C

    - (void)resetCursorRects

    Discussion

    Invokes discardCursorRects to clear the window’s cursor rectangles, then sends resetCursorRects to every NSView object in the window’s view hierarchy.

    This method is typically invoked by the NSApplication object when it detects that the key window’s cursor rectangles are invalid. In program code, it’s more efficient to invoke invalidateCursorRectsForView:.

    Availability

    Available in OS X v10.0 and later.

  • Returns a new instance of a given standard window button, sized appropriately for a given window style.

    Declaration

    Swift

    class func standardWindowButton(_ b: NSWindowButton, forStyleMask styleMask: Int) -> NSButton?

    Objective-C

    + (NSButton *)standardWindowButton:(NSWindowButton)windowButtonKind forStyleMask:(NSUInteger)windowStyle

    Parameters

    windowButtonKind

    The kind of standard window button to return.

    windowStyle

    The window style for which windowButtonKind is to be sized. See Window Style Masks for the list of allowable values.

    Return Value

    The new window button of the kind identified by windowButtonKind; nil when no such button kind exists.

    Discussion

    The caller is responsible for adding the button to the view hierarchy and for setting the target to be the window.

    Availability

    Available in OS X v10.2 and later.

  • Returns the window button of a given window button kind in the window’s view hierarchy.

    Declaration

    Swift

    func standardWindowButton(_ b: NSWindowButton) -> NSButton?

    Objective-C

    - (NSButton *)standardWindowButton:(NSWindowButton)windowButtonKind

    Parameters

    windowButtonKind

    The kind of standard window button to return.

    Return Value

    Window button in the window’s view hierarchy of the kind identified by windowButtonKind; nil when such button is not in the window’s view hierarchy.

    Availability

    Available in OS X v10.2 and later.

  • A Boolean value that indicates whether the toolbar control button is currently displayed.

    Declaration

    Swift

    var showsToolbarButton: Bool

    Objective-C

    @property BOOL showsToolbarButton

    Discussion

    The value of this property is YEStrue if the standard toolbar button is currently displayed; otherwise, NOfalse. When clicked, the toolbar control button shows or hides a window’s toolbar. The toolbar control button appears in a window’s title bar. If the window does not have a toolbar, this property has no effect.

    Availability

    Available in OS X v10.4 and later.

  • A Boolean value that indicates whether the title bar draws its background.

    Declaration

    Swift

    var titlebarAppearsTransparent: Bool

    Objective-C

    @property BOOL titlebarAppearsTransparent

    Discussion

    When the value of this property is YEStrue, the title bar does not draw its background, which allows all content underneath it to show through. It only makes sense to set this property to YEStrue when NSFullSizeContentViewWindowMask is also set.

    Availability

    Available in OS X v10.10 and later.

  • A Boolean value that indicates whether the window can display tooltips even when the application is in the background.

    Declaration

    Swift

    var allowsToolTipsWhenApplicationIsInactive: Bool

    Objective-C

    @property BOOL allowsToolTipsWhenApplicationIsInactive

    Discussion

    The value of this property is YEStrue if the window can display tooltips even when the application is in the background; otherwise, NOfalse. The default is NOfalse. Changing the value of this property does not take effect until the window changes to an active state.

    Availability

    Available in OS X v10.3 and later.

  • This method does nothing; it is here for backward compatibility.

    Declaration

    Swift

    class func menuChanged(_ menu: NSMenu)

    Objective-C

    + (void)menuChanged:(NSMenu *)menu

    Parameters

    menu

    The menu object that changed.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.11.

    See Also

    menu (NSResponder)

  • The event currently being processed by the application. (read-only)

    Declaration

    Swift

    var currentEvent: NSEvent? { get }

    Objective-C

    @property(readonly, strong) NSEvent *currentEvent

    Discussion

    The value of this property is given by calling by invoking the NSApplication method currentEvent.

    Availability

    Available in OS X v10.0 and later.

  • Returns the next event matching a given mask.

    Declaration

    Swift

    func nextEventMatchingMask(_ mask: Int) -> NSEvent?

    Objective-C

    - (NSEvent *)nextEventMatchingMask:(NSUInteger)eventMask

    Parameters

    eventMask

    The mask that the event to return must match. Events with non-matching masks are left in the queue. See discardEventsMatchingMask:beforeEvent: in NSApplication for the list of mask values.

    Return Value

    The next event whose mask matches eventMask; nil when no matching event was found.

    Discussion

    This method sends the message nextEventMatchingMask:eventMask untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES to the application (NSApp).

    Availability

    Available in OS X v10.0 and later.

  • Forwards the message to the global NSApplication object, NSApp.

    Declaration

    Swift

    func nextEventMatchingMask(_ mask: Int, untilDate expiration: NSDate?, inMode mode: String, dequeue deqFlag: Bool) -> NSEvent?

    Objective-C

    - (NSEvent *)nextEventMatchingMask:(NSUInteger)eventMask untilDate:(NSDate *)expirationDate inMode:(NSString *)runLoopMode dequeue:(BOOL)dequeue

    Parameters

    eventMask

    The mask that the event to return must match.

    expirationDate

    The date until which to wait for events.

    runLoopMode

    The run loop mode to use while waiting for events

    dequeue

    YEStrue to remove the returned event from the event queue; NOfalse to leave the returned event in the queue.

    Return Value

    The next event whose mask matches eventMask; nil when no matching event was found.

    Availability

    Available in OS X v10.0 and later.

  • Forwards the message to the NSApplication object, NSApp.

    Declaration

    Swift

    func discardEventsMatchingMask(_ mask: Int, beforeEvent lastEvent: NSEvent?)

    Objective-C

    - (void)discardEventsMatchingMask:(NSUInteger)eventMask beforeEvent:(NSEvent *)lastEvent

    Parameters

    eventMask

    The mask of the events to discard.

    lastEvent

    The event up to which queued events are discarded from the queue.

    Availability

    Available in OS X v10.0 and later.

    See Also

    discardEventsMatchingMask:beforeEvent: (NSApplication)

  • Forwards the message to the global NSApplication object, NSApp.

    Declaration

    Swift

    func postEvent(_ event: NSEvent, atStart flag: Bool)

    Objective-C

    - (void)postEvent:(NSEvent *)event atStart:(BOOL)atStart

    Parameters

    event

    The event to add to the window’s event queue.

    atStart

    YEStrue to place the event in the front of the queue; NOfalse to place it in the back.

    Availability

    Available in OS X v10.0 and later.

  • This action method dispatches mouse and keyboard events sent to the window by the NSApplication object.

    Declaration

    Swift

    func sendEvent(_ theEvent: NSEvent)

    Objective-C

    - (void)sendEvent:(NSEvent *)event

    Parameters

    event

    The mouse or keyboard event to process.

    Discussion

    Never invoke this method directly. A right mouse-down event in a window of an inactive application is not delivered to the corresponding NSWindow object. It is instead delivered to the NSApplication object through a sendEvent: message with a window number of 0.

    Availability

    Available in OS X v10.0 and later.

  • Dispatches action messages with a given argument.

    Declaration

    Swift

    func tryToPerform(_ anAction: Selector, with anObject: AnyObject?) -> Bool

    Objective-C

    - (BOOL)tryToPerform:(SEL)selector with:(id)object

    Parameters

    selector

    The selector to attempt to execute.

    object

    The message’s argument.

    Return Value

    YEStrue when the window or its delegate perform selector with object; otherwise, NOfalse.

    Discussion

    The window tries to perform the method selector using its inherited NSResponder method tryToPerform:with:. If the window doesn’t perform selector, the delegate is given the opportunity to perform it using its inherited NSObject method performSelector:withObject:.

    Availability

    Available in OS X v10.0 and later.

  • The view that’s made first responder (also called the key view) the first time the window is placed onscreen.

    Declaration

    Swift

    unowned(unsafe) var initialFirstResponder: NSView?

    Objective-C

    @property(assign) NSView *initialFirstResponder

    Availability

    Available in OS X v10.0 and later.

    See Also

    setNextKeyView: (NSView)

  • The window’s first responder. (read-only)

    Declaration

    Swift

    unowned(unsafe) var firstResponder: NSResponder { get }

    Objective-C

    @property(readonly, assign) NSResponder *firstResponder

    Discussion

    The first responder is usually the first object in a responder chain to receive an event or action message. In most cases, the first responder is a view object that the user selects or activates with the mouse or keyboard.

    You can use the firstResponder property in custom subclasses of responder classes (NSWindow, NSApplication, NSView, and subclasses) to determine if an instance of the subclass is currently the first responder. You can also use it to help locate a text field that currently has first-responder status. For more on this subject, see Event Handling Basics. This property is key-value observing compliant.

    Availability

    Available in OS X v10.0 and later.

  • Attempts to make a given responder the first responder for the window.

    Declaration

    Swift

    func makeFirstResponder(_ aResponder: NSResponder?) -> Bool

    Objective-C

    - (BOOL)makeFirstResponder:(NSResponder *)responder

    Parameters

    responder

    The responder to set as the window’s first responder. nil makes the window its first responder.

    Return Value

    YEStrue when the operation is successful; otherwise, NOfalse.

    Discussion

    If responder isn’t already the first responder, this method first sends a resignFirstResponder message to the object that is the first responder. If that object refuses to resign, it remains the first responder, and this method immediately returns NOfalse. If the current first responder resigns, this method sends a becomeFirstResponder message to responder. If responder does not accept first responder status, the NSWindow object becomes first responder; in this case, the method returns YEStrue even if responder refuses first responder status.

    If responder is nil, this method still sends resignFirstResponder to the current first responder. If the current first responder refuses to resign, it remains the first responder and this method immediately returns NOfalse. If the current first responder returns YEStrue from resignFirstResponder, the window is made its own first responder and this method returns YEStrue.

    The Application Kit framework uses this method to alter the first responder in response to mouse-down events; you can also use it to explicitly set the first responder from within your program. The responder object is typically an NSView object in the window’s view hierarchy. If this method is called explicitly, first send acceptsFirstResponder to responder, and do not call makeFirstResponder: if acceptsFirstResponder returns NOfalse.

    Use initialFirstResponder to the set the first responder to be used when the window is brought onscreen for the first time.

    Availability

    Available in OS X v10.0 and later.

    See Also

    becomeFirstResponder (NSResponder)
    resignFirstResponder (NSResponder)

  • A Boolean value that indicates whether the window accepts mouse-moved events.

    Declaration

    Swift

    var acceptsMouseMovedEvents: Bool

    Objective-C

    @property BOOL acceptsMouseMovedEvents

    Discussion

    The value of this property is YEStrue when the window accepts (and distributes) mouse-moved events; otherwise, NOfalse. By default the value is NOfalse.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window is transparent to mouse events.

    Declaration

    Swift

    var ignoresMouseEvents: Bool

    Objective-C

    @property BOOL ignoresMouseEvents

    Discussion

    The value of this property is YEStrue when the window is transparent to mouse events; otherwise, NOfalse.

    Availability

    Available in OS X v10.2 and later.

  • The current location of the pointer reckoned in the window’s base coordinate system, regardless of the current event being handled or of any events pending. (read-only)

    Declaration

    Swift

    var mouseLocationOutsideOfEventStream: NSPoint { get }

    Objective-C

    @property(readonly) NSPoint mouseLocationOutsideOfEventStream

    Discussion

    For the same information in screen coordinates, use NSEvent's mouseLocation.

    Availability

    Available in OS X v10.0 and later.

    See Also

    currentEvent (NSApplication)

  • Returns the number of the frontmost window that would be hit by a mouse-down at the specified screen location.

    Declaration

    Swift

    class func windowNumberAtPoint(_ point: NSPoint, belowWindowWithWindowNumber windowNumber: Int) -> Int

    Objective-C

    + (NSInteger)windowNumberAtPoint:(NSPoint)point belowWindowWithWindowNumber:(NSInteger)windowNumber

    Parameters

    point

    The location of the mouse-down in screen coordinates.

    windowNumber

    If non-0, the search will start below windowNumber window in z-order.

    Return Value

    The window number of the window under the point. The window number returned may correspond to a window in another application.

    Discussion

    Because this method uses the same rules as mouse-down hit-testing, windows with transparency at the given point, and windows that ignore mouse events, will not be returned.

    Availability

    Available in OS X v10.6 and later.

  • Tracks events that match the specified mask using the specified tracking handler until the tracking handler explicitly terminates tracking.

    Declaration

    Swift

    func trackEventsMatchingMask(_ mask: NSEventMask, timeout timeout: NSTimeInterval, mode mode: String, handler trackingHandler: (NSEvent, UnsafeMutablePointer<ObjCBool>) -> Void)

    Objective-C

    - (void)trackEventsMatchingMask:(NSEventMask)mask timeout:(NSTimeInterval)timeout mode:(NSString *)mode handler:(void (^)(NSEvent *event, BOOL *stop))trackingHandler

    Parameters

    mask

    The event mask (see NSEventMask in NSEvent Class Reference for possible values).

    timeout

    The maximum time interval the system waits for an event before passing nil to the handler.

    mode

    The run loop mode.

    trackingHandler

    A block that is called to track the events. The block takes the following parameters:

    event

    The event to examine.

    stop

    A Boolean value that indicates when tracking should stop.

    Discussion

    You can use this method in a tracking loop to get pressure events when you add NSEventMaskPressure to the event mask. This method returns when tracking terminates.

    Each event is removed from the event queue and then passed to the tracking handler. If a matching event does not exist in the event queue, the main thread blocks in the specified runloop mode until an event of the requested type is received or the specified timeout expires. If the timeout expires, the tracking handler is called with a nil event (a negative timeout is interpreted as 0). Use NSEventDurationForever to prevent timing out. Tracking continues until you set stop to YEStrue. Note that calls to nextEventMatchingMask: are allowed inside the trackingHandler block.

    Availability

    Available in OS X v10.10 and later.

  • A Boolean value indicating whether the window configuration is preserved between application launches.

    Declaration

    Swift

    var restorable: Bool

    Objective-C

    @property(getter=isRestorable) BOOL restorable

    Discussion

    Set this property to YEStrue if you want the window to be preserved or NOfalse if you do not want it preserved. By default, the value of this property is YEStrue if the window’s styleMask property includes the NSTitledWindowMask flag. For other windows, the value is NOfalse. Setting a value explicitly overrides the default values.

    Windows should be preserved between launch cycles to maintain interface continuity for the user. During subsequent launch cycles, the system tries to recreate the window and restore its configuration to the preserved state. Configuration data is updated as needed and saved automatically by the system.

    If you enable preservation for a given window, you should also specify a restoration class for the window using the restorationClass property.

    Availability

    Available in OS X v10.7 and later.

  • The restoration class associated with the window.

    Declaration

    Swift

    var restorationClass: AnyObject.Type?

    Objective-C

    @property(assign) Class< NSWindowRestoration > restorationClass

    Discussion

    The value of this property is a class object that conforms to the NSWindowRestoration protocol corresponding to the class to use to restore the window or nil if none is set.

    The restoration class of a window is responsible for recreating not just the window but any other objects needed to manage the window. This almost always involves creating a window controller and for multi-window document applications also involves creating a document object. Therefore, the restoration class must be able to create (or find existing instances of) all of these objects at launch time in your application. When prompted by AppKit, the restoration class creates or acquires a window that matches the same type that was preserved. It then passes that window back to AppKit, which proceeds to reconfigure the window with the preserved state information.

    If you mark your windows as restorable, you must associate a restoration class with them. For multi-window document applications, AppKit associates the NSDocumentController class with any document windows by default. That class recreates the preserved document objects, which in turn recreate the corresponding window controller and window objects. For other types of windows, you must set the restoration class explicitly.

    Availability

    Available in OS X v10.7 and later.

  • Disable snapshot restoration.

    Declaration

    Swift

    func disableSnapshotRestoration()

    Objective-C

    - (void)disableSnapshotRestoration

    Discussion

    While snapshot restoration is disabled, the window will not be snapshotted for restorable state.

    Availability

    Available in OS X v10.7 and later.

  • Enable snapshot restoration.

    Declaration

    Swift

    func enableSnapshotRestoration()

    Objective-C

    - (void)enableSnapshotRestoration

    Discussion

    While snapshot restoration is enabled, the window will be snapshotted for restorable state.

    Availability

    Available in OS X v10.7 and later.

  • Stores the window’s raster image from a given rectangle expressed in the window’s base coordinate system.

    Declaration

    Swift

    func cacheImageInRect(_ aRect: NSRect)

    Objective-C

    - (void)cacheImageInRect:(NSRect)rectangle

    Parameters

    rectangle

    The rectangle representing the image to cache.

    Discussion

    This method allows the window to perform temporary drawing, such as a band around the selection as the user drags the mouse, and to quickly restore the previous image by invoking restoreCachedImage and flushWindowIfNeeded. The next time the window displays, it discards its cached image rectangles. You can also explicitly use discardCachedImage to free the memory occupied by cached image rectangles. aRect is made integral before caching the image to avoid antialiasing artifacts.

    Only the last cached rectangle is remembered and can be restored.

    Availability

    Available in OS X v10.0 and later.

    See Also

    – display

  • Splices the window’s cached image rectangles, if any, back into its raster image (and buffer if it has one), undoing the effect of any drawing performed within those areas since they were established using cacheImageInRect:.

    Declaration

    Swift

    func restoreCachedImage()

    Objective-C

    - (void)restoreCachedImage

    Discussion

    You must invoke flushWindow after this method to guarantee proper redisplay. An NSWindow object automatically discards its cached image rectangles when it displays.

    Availability

    Available in OS X v10.0 and later.

  • Discards all of the window’s cached image rectangles.

    Declaration

    Swift

    func discardCachedImage()

    Objective-C

    - (void)discardCachedImage

    Discussion

    An NSWindow object automatically discards its cached image rectangles when it displays.

    Availability

    Available in OS X v10.0 and later.

  • Passes a display message down the window’s view hierarchy, thus redrawing all views within the window, including the frame view that draws the border, title bar, and other peripheral elements.

    Declaration

    Swift

    func display()

    Objective-C

    - (void)display

    Discussion

    You rarely need to invoke this method. NSWindow objects normally record which of their views need display and display them automatically on each pass through the event loop.

    Availability

    Available in OS X v10.0 and later.

  • Passes a displayIfNeeded message down the window’s view hierarchy, thus redrawing all views that need to be displayed, including the frame view that draws the border, title bar, and other peripheral elements.

    Declaration

    Swift

    func displayIfNeeded()

    Objective-C

    - (void)displayIfNeeded

    Discussion

    This method is useful when you want to modify some number of views and then display only the ones that were modified.

    You rarely need to invoke this method. NSWindow objects normally record which of their views need display and display them automatically on each pass through the event loop.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether any of the window’s views need to be displayed.

    Declaration

    Swift

    var viewsNeedDisplay: Bool

    Objective-C

    @property BOOL viewsNeedDisplay

    Discussion

    The value of this property is YEStrue when any of the window’s views need to be displayed; otherwise, NOfalse. You should rarely need to set this property; the NSView method setNeedsDisplay: and similar methods set it automatically.

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window automatically displays views that need to be displayed.

    Declaration

    Swift

    var autodisplay: Bool

    Objective-C

    @property(getter=isAutodisplay) BOOL autodisplay

    Discussion

    The value of this property is YEStrue when the window automatically displays views that need to be displayed; otherwise, NOfalse. If autodisplay is NOfalse, the window or its views must be explicitly displayed.

    Automatic display typically occurs on each pass through the event loop.

    Availability

    Available in OS X v10.0 and later.

  • Specifies whether the window is to optimize focusing and drawing when displaying its views.

    Declaration

    Swift

    func useOptimizedDrawing(_ flag: Bool)

    Objective-C

    - (void)useOptimizedDrawing:(BOOL)optimizedDrawing

    Parameters

    optimizedDrawing

    If YEStrue, the window will optimize focusing and drawing for its views; if NOfalse, it will not, in which case, the window does not preserve the Z-ordering of overlapping views when an object explicitly sends lockFocus to a view and draws directly to it, instead of using the AppKit standard display mechanism.

    Discussion

    The optimizations may prevent sibling subviews from being displayed in the correct order—which matters only if the subviews overlap. You should always set optimizedDrawing to YEStrue when there are no overlapping subviews within the window. The default is NOfalse.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.10.

  • The graphics context associated with the window for the current thread. (read-only)

    Declaration

    Swift

    var graphicsContext: NSGraphicsContext? { get }

    Objective-C

    @property(readonly, strong) NSGraphicsContext *graphicsContext

    Availability

    Available in OS X v10.4 and later.

  • A Boolean value that indicates whether the window allows multithreaded view drawing.

    Declaration

    Swift

    var allowsConcurrentViewDrawing: Bool

    Objective-C

    @property BOOL allowsConcurrentViewDrawing

    Discussion

    The value of this property is YEStrue if the window allows multithreaded view drawing; otherwise, NOfalse. The default value is YEStrue.

    Availability

    Available in OS X v10.6 and later.

  • The window’s automatic animation behavior.

    Declaration

    Swift

    var animationBehavior: NSWindowAnimationBehavior

    Objective-C

    @property NSWindowAnimationBehavior animationBehavior

    Discussion

    This property controls the automatic window animation behavior used when the orderFront: or orderOut: methods are called. See NSWindowAnimationBehavior for the possible values of this property.

    By default, a window’s animation behavior is set to NSWindowAnimationBehaviorDefault, which causes AppKit to determine the style of animation to use automatically based on its inference of a window’s “type” from various window properties. A window’s animation behavior can be set to NSWindowAnimationBehaviorNone to disable AppKit’s automatic animations for the window, which may be useful if that animation interferes with an animation that your application implements.

    The animation behavior can also be set to one of the other non-default NSWindowAnimationBehavior values to override AppKit's automatic inference of appropriate animation behavior based on the window's apparent type, although this is not recommended.

    Availability

    Available in OS X v10.7 and later.

  • Disables the window’s screen updates until the window is flushed.

    Declaration

    Swift

    func disableScreenUpdatesUntilFlush()

    Objective-C

    - (void)disableScreenUpdatesUntilFlush

    Discussion

    This method can be invoked to synchronize hardware surface flushes with the window’s flushes. The window immediately disables screen updates using the NSDisableScreenUpdates function and reenables screen updates when the window flushes. Sending this message multiple times during a window update cycle has no effect.

    To ensure that screen updates are reenabled in a timely manner, it’s crucial that the window is marked as needing display and that the display will occur soon (that is, within the next second). When you invoke disableScreenUpdatesUntilFlush, you can make sure that a marked window gets displayed by returning control to the run loop on the main thread or by sending the window displayIfNeeded or display. If it’s unclear whether the window is marked as needing display, you can also ensure that a display occurs by using setNeedsDisplayInRect: for a view that’s visible in the window.

    Availability

    Available in OS X v10.4 and later.

  • Updates the window.

    Declaration

    Swift

    func update()

    Objective-C

    - (void)update

    Discussion

    The NSWindow implementation of this method does nothing more than post an NSWindowDidUpdateNotification notification to the default notification center. A subclass can override this method to perform specialized operations, but it should send an update message to super just before returning. For example, the NSMenu class implements this method to disable and enable menu commands.

    An NSWindow object is automatically sent an update message on every pass through the event loop and before it’s displayed onscreen. You can manually cause an update message to be sent to all visible NSWindow objects through the NSApplication updateWindows method.

    Availability

    Available in OS X v10.0 and later.

    See Also

    setWindowsNeedUpdate: (NSApplication)

  • Begins a dragging session.

    Declaration

    Swift

    func dragImage(_ anImage: NSImage, at baseLocation: NSPoint, offset initialOffset: NSSize, event event: NSEvent, pasteboard pboard: NSPasteboard, source sourceObj: AnyObject, slideBack slideFlag: Bool)

    Objective-C

    - (void)dragImage:(NSImage *)image at:(NSPoint)imageLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pasteboard source:(id)sourceObject slideBack:(BOOL)slideBack

    Parameters

    image

    The object to be dragged.

    imageLocation

    Location of the image’s bottom-left corner in the window’s coordinate system. It determines the placement of the dragged image under the pointer.

    initialOffset

    The pointer’s location relative to the mouse-down location. Not used in OS X v10.4 and later.

    event

    The left-mouse down event that triggered the dragging operation.

    pasteboard

    The pasteboard that holds the data to be transferred to the destination.

    sourceObject

    The object serving as the controller of the dragging operation. It must conform to the NSDraggingSource protocol.

    slideBack

    Specifies whether the drag image should slide back to imageLocation if it's rejected by the drag destination. Pass YEStrue to specify slide back behavior or NOfalse to specify that it should not.

    Discussion

    This method should be invoked only from within a view’s implementation of the mouseDown: or mouseDragged: methods (which overrides the version defined in NSResponder class). Essentially the same as the NSView method of the same name, except that imageLocation is given in the NSWindow object’s base coordinate system.

    Availability

    Available in OS X v10.0 and later.

  • Registers a give set of pasteboard types as the pasteboard types the window will accept as the destination of an image-dragging session.

    Declaration

    Swift

    func registerForDraggedTypes(_ newTypes: [String])

    Objective-C

    - (void)registerForDraggedTypes:(NSArray<NSString *> *)pasteboardTypes

    Parameters

    pasteboardTypes

    An array of the pasteboard types the window will accept as the destination of an image-dragging session.

    Discussion

    Registering an NSWindow object for dragged types automatically makes it a candidate destination object for a dragging session. NSWindow has a default implementation for many of the methods in the NSDraggingDestination protocol. The default implementation forwards each message to the delegate if the delegate responds to the selector of the message. The messages forwarded this way are draggingEntered:, draggingUpdated:, draggingExited:, prepareForDragOperation:, performDragOperation:, and concludeDragOperation:.

    Availability

    Available in OS X v10.0 and later.

  • Unregisters the window as a possible destination for dragging operations.

    Declaration

    Swift

    func unregisterDraggedTypes()

    Objective-C

    - (void)unregisterDraggedTypes

    Availability

    Available in OS X v10.0 and later.

  • A Boolean value that indicates whether the window’s document has been edited.

    Declaration

    Swift

    var documentEdited: Bool

    Objective-C

    @property(getter=isDocumentEdited) BOOL documentEdited

    Discussion

    The value of this property is YEStrue when the window’s document has been edited; otherwise, NOfalse. Initially, by default, NSWindow objects are in the “not edited” state.

    You should set documentEdited to YEStrue every time the window’s document changes in such a way that it needs to be saved. Conversely, when the document is saved, you should set the property to YEStrue when the window’s document has been edited; otherwise, NOfalse. Then, before closing the window you can examine the value of the property to determine whether to allow the user a chance to save the document.

    Availability

    Available in OS X v10.0 and later.

  • The backing scale factor. (read-only)

    Declaration

    Swift

    var backingScaleFactor: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat backingScaleFactor

    Discussion

    The value of this property is 2.0 for high-resolution scaled display modes, and 1.0 for all other cases.

    There are some scenarios where an application that is resolution-aware may want to reason on its own about the display environment it is running in.

    It is important to note that the value of this property does not represent anything concrete, such as pixel density or physical size, because it can vary based on the configured display mode. For example, the display may be in a mirrored configuration that is still high-resolution scaled, resulting in pixel geometry that may not match the native resolution of the display device.

    Availability

    Available in OS X v10.7 and later.

  • Returns a backing store pixel aligned rectangle in window coordinates.

    Declaration

    Swift

    func backingAlignedRect(_ aRect: NSRect, options options: NSAlignmentOptions) -> NSRect

    Objective-C

    - (NSRect)backingAlignedRect:(NSRect)aRect options:(NSAlignmentOptions)options

    Parameters

    aRect

    The rectangle in view coordinates.

    options

    The alignment options. See NSAlignmentOptions for possible values.

    Return Value

    A rectangle that is aligned to the backing store pixels using the specified options. The rectangle is in window coordinates.

    Discussion

    Uses the NSIntegralRectWithOptions function to produce a backing store pixel aligned rectangle from the given input rectangle in window coordinates.

    Availability

    Available in OS X v10.7 and later.

  • Converts a rect from its pixel aligned backing store coordinate system to the window’s coordinate system.

    Declaration

    Swift

    func convertRectFromBacking(_ aRect: NSRect) -> NSRect

    Objective-C

    - (NSRect)convertRectFromBacking:(NSRect)aRect

    Parameters

    aRect

    The rect in the pixel backing store aligned coordinate system.

    Return Value

    A rect in the window’s coordinate system.

    Availability

    Available in OS X v10.7 and later.

  • Converts a rectangle from the window’s coordinate system to its pixel aligned backing store coordinate system.

    Declaration

    Swift

    func convertRectToBacking(_ aRect: NSRect) -> NSRect

    Objective-C

    - (NSRect)convertRectToBacking:(NSRect)aRect

    Parameters

    aRect

    A rectangle in the window’s coordinate system.

    Return Value

    A rectangle in its pixel aligned backing store coordinate system.

    Availability

    Available in OS X v10.7 and later.

  • Converts the rectangle to the screen coordinate system from the window’s coordinate system.

    Declaration

    Swift

    func convertRectToScreen(_ aRect: NSRect) -> NSRect

    Objective-C

    - (NSRect)convertRectToScreen:(NSRect)aRect

    Parameters

    aRect

    A rectangle in the window’s coordinate system.

    Return Value

    A rectangle in the screen’s coordinate system.

    Availability

    Available in OS X v10.7 and later.

  • Converts the rectangle from the screen coordinate system to the window’s coordinate system

    Declaration

    Swift

    func convertRectFromScreen(_ aRect: NSRect) -> NSRect

    Objective-C

    - (NSRect)convertRectFromScreen:(NSRect)aRect

    Parameters

    aRect

    A rectangle in the screen’s coordinate system.

    Return Value

    A rectangle in the window’s coordinate system.

    Availability

    Available in OS X v10.7 and later.

  • Converts a given point from the window’s base coordinate system to the screen coordinate system.

    Deprecation Statement

    Use convertRectToScreen: instead.

    Declaration

    Objective-C

    - (NSPoint)convertBaseToScreen:(NSPoint)point

    Parameters

    point

    The point expressed in the window’s base coordinate system.

    Return Value

    point expressed in screen coordinates.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.7.

  • Converts a given point from the screen coordinate system to the window’s base coordinate system.

    Deprecation Statement

    Use convertRectFromScreen: instead.

    Declaration

    Objective-C

    - (NSPoint)convertScreenToBase:(NSPoint)point

    Parameters

    point

    The point expressed in screen coordinates.

    Return Value

    point expressed in the window’s base coordinate system.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.7.

  • Returns the scale factor applied to the window.

    Deprecation Statement

    Use convertRectToBacking: and backingScaleFactor instead.

    Declaration

    Objective-C

    - (CGFloat)userSpaceScaleFactor

    Return Value

    The scale factor applied to the window.

    Discussion

    Clients can multiply view coordinates by the returned scale factor to get a set of new coordinates that are scaled to the resolution of the target screen. For example, if the scale factor is 1.25 and the view frame size is 80 x 80, the actual size of the view frame is 100 x 100 pixels on the target screen.

    Availability

    Available in OS X v10.4 and later.

    Deprecated in OS X v10.7.

  • The string that appears in the title bar of the window or the path to the represented file.

    Declaration

    Swift

    var title: String

    Objective-C

    @property(copy) NSString *title

    Discussion

    If the title has been set using setTitleWithRepresentedFilename:, this property contains the file’s path. Setting this property also sets the title of the window’s miniaturized window.

    Availability

    Available in OS X v10.0 and later.

  • A value that indicates the visibility of the window’s title and title bar buttons.

    Declaration

    Swift

    var titleVisibility: NSWindowTitleVisibility

    Objective-C

    @property NSWindowTitleVisibility titleVisibility

    Discussion

    By default, the value of this property is NSWindowTitleVisible.

    Availability

    Available in OS X v10.10 and later.

  • Sets a given path as the window’s title, formatting it as a file-system path, and records this path as the window’s associated filename using representedFilename.

    Declaration

    Swift

    func setTitleWithRepresentedFilename(_ filename: String)

    Objective-C

    - (void)setTitleWithRepresentedFilename:(NSString *)filePath

    Parameters

    filePath

    The file path to set as the window’s title.

    Discussion

    The filename—not the pathname—is displayed in the window’s title bar.

    Availability

    Available in OS X v10.0 and later.

  • The path to the file of the window’s represented file.

    Declaration

    Swift

    var representedFilename: String

    Objective-C

    @property(copy) NSString *representedFilename

    Availability

    Available in OS X v10.0 and later.

  • The URL of the file the window represents.

    Declaration

    Swift

    @NSCopying var representedURL: NSURL?

    Objective-C

    @property(copy) NSURL *representedURL

    Discussion

    When the URL specifies a path, the window shows an icon in its title bar, as described in Table 1.

    Table 1Title bar document icon display

    File path

    Document icon

    Empty

    None

    Specifies a nonexistent file

    Generic

    Specifies an existent file

    Specific for the file’s type

    You can customize the file icon in the title bar with the following code:

    1. [[<window> standardWindowButton:NSWindowDocumentIconButton] setImage:<image>]

    When the URL identifies an existing file, the window’s title offers a pop-up menu showing the path components of the URL. (The user displays this menu by Command-clicking the title.) The behavior and contents of this menu can be controlled with window:shouldPopUpDocumentPathMenu:.

    Availability

    Available in OS X v10.5 and later.

  • The screen the window is on. (read-only)

    Declaration

    Swift

    var screen: NSScreen? { get }

    Objective-C

    @property(readonly, strong) NSScreen *screen

    Discussion

    The value of this property is the screen where most of the window is on; it is nil when the window is offscreen.

    Availability

    Available in OS X v10.0 and later.

    See Also

    deepestScreen

  • The deepest screen the window is on (it may be split over several screens). (read-only)

    Declaration

    Swift

    var deepestScreen: NSScreen? { get }

    Objective-C

    @property(readonly, strong) NSScreen *deepestScreen

    Discussion

    The value of this property is nil when the window is offscreen.

    Availability

    Available in OS X v10.0 and later.

    See Also

    screen

  • A Boolean value that indicates whether the window context should be updated when the screen profile changes or when the window moves to a different screen.

    Declaration

    Swift

    var displaysWhenScreenProfileChanges: Bool

    Objective-C

    @property BOOL displaysWhenScreenProfileChanges

    Discussion

    The value of this property is YEStrue when the window context should be updated when the ColorSync profile of the current screen changes or when a majority of the window is moved to a different screen whose profile is different than the previous screen; otherwise, NOfalse. The default value is NOfalse.

    After the window context is updated, the window is told to display itself. If you need to update offscreen caches for the window, you should register to receive the NSWindowDidChangeScreenProfileNotification notification.

    Availability

    Available in OS X v10.4 and later.

  • A Boolean value that indicates whether the window is movable by clicking and dragging anywhere in its background.

    Declaration

    Swift

    var movableByWindowBackground: Bool

    Objective-C

    @property(getter=isMovableByWindowBackground) BOOL movableByWindowBackground

    Discussion

    The value of this property is YEStrue when the window is movable by clicking and dragging anywhere in its background; otherwise, NOfalse.

    A window with a style mask of NSTexturedBackgroundWindowMask is movable by background by default. Sheets and drawers cannot be movable by window background.

    Availability

    Available in OS X v10.2 and later.

  • A Boolean value that indicates whether the window can be dragged by clicking in its title bar or background.

    Declaration

    Swift

    var movable: Bool

    Objective-C

    @property(getter=isMovable) BOOL movable

    Discussion

    The value of this property is YEStrue if the window can be moved by the user; otherwise, NOfalse.

    When a window’s movable property is NOfalse, the value of the movableByWindowBackground property is ignored. When the value of movable is NOfalse, the window can only be dragged between spaces in F8 mode, and its relative screen position is always preserved. Note that a resizable window may still be resized, and the window frame may be changed programmatically. A nonmovable window will not be moved or resized by the system in response to a display reconfiguration. Applications may choose to enable application-controlled window dragging after disabling user-initiating dragging by handling the mouseDown:/mouseDragged:/mouseUp: sequence in sendEvent: in an NSWindow subclass.

    Availability

    Available in OS X v10.6 and later.

  • Sets the window’s location to the center of the screen.

    Declaration

    Swift

    func center()

    Objective-C

    - (void)center

    Discussion

    The window is placed exactly in the center horizontally and somewhat above center vertically. Such a placement carries a certain visual immediacy and importance. This method doesn’t put the window onscreen, however; use makeKeyAndOrderFront: to do that.

    You typically use this method to place a window—most likely an alert dialog—where the user can’t miss it. This method is invoked automatically when a panel is placed on the screen by the runModalForWindow: method of the NSApplication class.

    Availability

    Available in OS X v10.0 and later.

  • This action method simulates the user clicking the close button by momentarily highlighting the button and then closing the window.

    Declaration

    Swift

    func performClose(_ sender: AnyObject?)

    Objective-C

    - (void)performClose:(id)sender

    Parameters

    sender

    The message’s sender.

    Discussion

    If the window’s delegate or the window itself implements windowShouldClose:, that message is sent with the window as the argument. (Only one such message is sent; if both the delegate and the NSWindow object implement the method, only the delegate receives the message.) If the windowShouldClose: method returns NOfalse, the window isn’t closed. If it returns YEStrue, or if it isn’t implemented, performClose: invokes the close method to close the window.

    If the window doesn’t have a close button or can’t be closed (for example, if the delegate replies NOfalse to a windowShouldClose: message), the system emits the alert sound.

    Availability

    Available in OS X v10.0 and later.

  • Removes the window from the screen.

    Declaration

    Swift

    func close()

    Objective-C

    - (void)close

    Discussion

    If the window is set to be released when closed, a release message is sent to the object after the current event is completed. For an NSWindow object, the default is to be released on closing, while for an NSPanel object, the default is not to be released. You can use the releasedWhenClosed property to change the default behavior.

    A window doesn’t have to be visible to receive the close message. For example, when the application terminates, it sends the close message to all windows in its window list, even those that are not currently visible.

    The close method posts an NSWindowWillCloseNotification notification to the default notification center.

    The close method differs in two important ways from the performClose: method:

    • It does not attempt to send a windowShouldClose: message to the window or its delegate.

    • It does not simulate the user clicking the close button by momentarily highlighting the button.

    Use performClose: if you need these features.

    Availability

    Available in OS X v10.0 and later.

    See Also

    – orderOut:

  • A Boolean value that indicates whether the window is released when it receives the close message.

    Declaration

    Swift

    var releasedWhenClosed: Bool

    Objective-C

    @property(getter=isReleasedWhenClosed) BOOL releasedWhenClosed

    Discussion

    The value of this property is YEStrue if the window is automatically released after being closed; NOfalse if it’s simply removed from the screen.

    The default for NSWindow is YEStrue; the default for NSPanel is NOfalse. Release when closed, however, is ignored for windows owned by window controllers. Another strategy for releasing an NSWindow object is to have its delegate autorelease it on receiving a windowShouldClose: message.

    Availability

    Available in OS X v10.0 and later.

    See Also

    – close

  • A Boolean value that indicates whether the window is minimized. (read-only)

    Declaration

    Swift

    var miniaturized: Bool { get }

    Objective-C

    @property(getter=isMiniaturized, readonly) BOOL miniaturized

    Discussion

    The value of this property is YEStrue if the window is minimized; otherwise, NOfalse. A minimized window is removed from the screen and replaced by a image, icon, or button that represents it, called the counterpart.

    Availability

    Available in OS X v10.0 and later.

  • Simulates the user clicking the minimize button by momentarily highlighting the button, then minimizing the window.

    Declaration

    Swift

    func performMiniaturize(_ sender: AnyObject?)

    Objective-C

    - (void)performMiniaturize:(id)sender

    Parameters

    sender

    The message’s sender.

    Discussion

    If the window doesn’t have a minimize button or can’t be minimized for some reason, the system emits the alert sound.

    Availability

    Available in OS X v10.0 and later.

  • Removes the window from the screen list and displays the minimized window in the Dock.

    Declaration

    Swift

    func miniaturize(_ sender: AnyObject?)

    Objective-C

    - (void)miniaturize:(id)sender

    Parameters

    sender

    The message’s sender.

    Availability

    Available in OS X v10.0 and later.

  • De-minimizes the window.

    Declaration

    Swift

    func deminiaturize(_ sender: AnyObject?)

    Objective-C

    - (void)deminiaturize:(id)sender

    Parameters

    sender

    The message’s sender.

    Discussion

    Invoke this method to programmatically deminimize a minimized window in the Dock.

    Availability

    Available in OS X v10.0 and later.