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.
More...
Conforms To
-
AnyObject -
CVarArgType -
Equatable -
Hashable -
NSAccessibility -
NSAccessibilityElementProtocol -
NSAnimatablePropertyContainer -
NSAppearanceCustomization -
NSCoding -
NSObjectProtocol -
NSUserInterfaceItemIdentification -
NSUserInterfaceValidations -
Printable -
NSAccessibility -
NSAccessibilityElement -
NSAnimatablePropertyContainer -
NSAppearanceCustomization -
NSCoding -
NSObject -
NSUserInterfaceItemIdentification -
NSUserInterfaceValidations
Import Statement
import AppKit
@import AppKit;
Availability
Available in OS X v10.0 and later.
-
Initializes the window with the specified values.
Declaration
Swift
init(contentRectcontentRect: NSRect, styleMaskwindowStyle: Int, backingbufferingType: NSBackingStoreType, deferdeferCreation: Bool)Objective-C
- (instancetype)initWithContentRect:(NSRect)contentRectstyleMask:(NSUInteger)windowStylebacking:(NSBackingStoreType)bufferingTypedefer:(BOOL)deferCreationParameters
contentRectOrigin 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.
windowStyleThe 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 includeNSTitledWindowMaskif it includes any of the others.bufferingTypeSpecifies how the drawing done in the window is buffered by the window device, and possible values are described in NSBackingStoreType—Buffered Window Drawing.
deferCreationSpecifies 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
NSWindowclass.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 using the
setContentView:method.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
init(contentRect:styleMask:backing:defer:screen:) initWithContentRect:styleMask:backing:defer:screen:Initializes an allocated window with the specified values.
Declaration
Swift
convenience init(contentRectcontentRect: NSRect, styleMaskwindowStyle: Int, backingbufferingType: NSBackingStoreType, deferdeferCreation: Bool, screenscreen: NSScreen?)Objective-C
- (instancetype)initWithContentRect:(NSRect)contentRectstyleMask:(NSUInteger)windowStylebacking:(NSBackingStoreType)bufferingTypedefer:(BOOL)deferCreationscreen:(NSScreen *)screenParameters
contentRectOrigin 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.
windowStyleThe 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 includeNSTitledWindowMaskif it includes any of the others.bufferingTypeSpecifies how the drawing done in the window is buffered by the window device; possible values are described in NSBackingStoreType—Buffered Window Drawing.
deferCreationSpecifies 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.screenSpecifies the screen on which the window is positioned. The content rectangle is positioned relative to the bottom-left corner of
screen. Whennil, 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.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the window’s style mask, indicating what kinds of control items it displays.
Return Value
The window’s style mask.
Discussion
See the information about the style mask in Window Style Masks.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets the window’s style mask to the given value.
Declaration
Objective-C
- (void)setStyleMask:(NSUInteger)styleMaskParameters
styleMaskThe new style mask value. See Window Style Masks for possible values.
Discussion
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.Import Statement
Availability
Available in OS X v10.6 and later.
See Also
-
Taken the window into or out of fullscreen mode,
Declaration
Swift
func toggleFullScreen(_sender: AnyObject?)Objective-C
- (void)toggleFullScreen:(id)senderParameters
senderThe 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, andnilas the target.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Indicates whether the window is able to receive keyboard and mouse events even when some other window is being run modally.
Declaration
Swift
var worksWhenModal: Bool { get }Objective-C
@property(readonly) BOOL worksWhenModalReturn Value
YEStrueif the window is able to receive keyboard and mouse events even when some other window is being run modally; otherwise,NOfalse.Discussion
The
NSWindowimplementation of this method returnsNOfalse. Only subclasses ofNSPanelshould override this default.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
setWorksWhenModal:(NSPanel) -
Returns the window’s alpha value.
Declaration
Swift
var alphaValue: CGFloatObjective-C
@property CGFloat alphaValueReturn Value
The window’s alpha value.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Applies a given alpha value to the entire window.
Declaration
Swift
var alphaValue: CGFloatObjective-C
@property CGFloat alphaValueParameters
windowAlphaThe alpha value to apply.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the color of the window’s background.
Declaration
Swift
@NSCopying var backgroundColor: NSColor!Objective-C
@property(copy) NSColor *backgroundColorReturn Value
The window’s background color.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets the window’s background color to the given color.
Declaration
Swift
@NSCopying var backgroundColor: NSColor!Objective-C
@property(copy) NSColor *backgroundColorParameters
colorColor to set as the window’s background color.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the window’s color space.
Declaration
Swift
var colorSpace: NSColorSpace?Objective-C
@property(strong) NSColorSpace *colorSpaceReturn Value
The color space. Will return
nilIf the window does not have a backing store, and is off-screen.Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
See Also
-
Sets the window’s color space.
Declaration
Swift
var colorSpace: NSColorSpace?Objective-C
@property(strong) NSColorSpace *colorSpaceParameters
colorSpaceThe color space to set.
Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
See Also
-
Returns the window’s content view, the highest accessible
NSViewobject in the window’s view hierarchy.Declaration
Swift
var contentView: AnyObject?Objective-C
@property(strong) id contentViewReturn Value
The content view.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Makes a given view the window’s content view.
Declaration
Swift
var contentView: AnyObject?Objective-C
@property(strong) id contentViewParameters
viewView that is to become the window’s content view.
Discussion
The window retains the new content view and owns it thereafter. The
viewobject 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.This method causes the old content view to be released; if you plan to reuse it, be sure to retain it before sending this message and to release it as appropriate when adding it to another
NSWindowobject orNSView.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Indicates whether the window can be hidden when its application becomes hidden (during execution of the
NSApplicationhide:method).Declaration
Swift
var canHide: BoolObjective-C
@property BOOL canHideReturn Value
YEStrueif the window can be hidden when its application becomes hidden; otherwise,NOfalse.Discussion
The default is
YEStrue.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Specifies whether the window can be hidden when its application becomes hidden (during execution of the
NSApplicationhide:method).Declaration
Swift
var canHide: BoolObjective-C
@property BOOL canHideParameters
canHideIf
YEStrue, the window can be hidden when its application becomes hidden; ifNOfalse, it cannot.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
canBeVisibleOnAllSpaces canBeVisibleOnAllSpaces(OS X v10.5)Indicates whether the window can be visible on all spaces or on only one space at a time.
Deprecation Statement
Use
setCollectionBehavior:instead.Declaration
Objective-C
- (BOOL)canBeVisibleOnAllSpacesReturn Value
YEStruewhen the window can be visible on all spaces;NOfalsewhen it can be visible on only one space at a time.Discussion
The default is
NOfalse.Import Statement
Availability
Available in OS X v10.5 and later.
Deprecated in OS X v10.5.
-
setCanBeVisibleOnAllSpaces: setCanBeVisibleOnAllSpaces:(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
collectionBehaviorinstead.Declaration
Objective-C
- (void)setCanBeVisibleOnAllSpaces:(BOOL)flagParameters
flagYEStruespecifies that the window can be visible on all spaces;NOfalsespecifies that the window can be visible on only one space at a time.Import Statement
Availability
Available in OS X v10.5 and later.
Deprecated in OS X v10.5.
-
isOnActiveSpace isOnActiveSpaceAvailable in OS X v10.6 through OS X v10.9Indicates whether the window is on the currently active space.
Declaration
Objective-C
- (BOOL)isOnActiveSpaceReturn Value
YEStrueif the window is on the currently active space; otherwise,NOfalse.Discussion
For visible windows, this method indicates whether the window is currently visible on the active space. For non-visible windows, it indicates whether ordering the window onscreen would cause it to be on the active space.
Import Statement
Availability
Available in OS X v10.6 through OS X v10.9.
-
Indicates whether the window is removed from the screen when its application becomes inactive.
Declaration
Swift
var hidesOnDeactivate: BoolObjective-C
@property BOOL hidesOnDeactivateReturn Value
YEStrueif the window is removed from the screen when its application is deactivated;NOfalseif it remains onscreen.Discussion
The default for
NSWindowisNOfalse; the default forNSPanelisYEStrue.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Specifies whether the window is removed from the screen when the application is inactive.
Declaration
Swift
var hidesOnDeactivate: BoolObjective-C
@property BOOL hidesOnDeactivateParameters
hideOnDeactivateYEStruespecifies that the window is to be hidden (taken out of the screen list) when the application stops being the active applicationNOfalsespecifies that the window is to remain onscreen when the application becomes inactive.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Identifies the window’s behavior in window collections.
Declaration
Swift
var collectionBehavior: NSWindowCollectionBehaviorObjective-C
@property NSWindowCollectionBehavior collectionBehaviorReturn Value
The collection behavior identifier.
Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
-
Specifies the window’s behavior in window collections.
Declaration
Swift
var collectionBehavior: NSWindowCollectionBehaviorObjective-C
@property NSWindowCollectionBehavior collectionBehaviorParameters
collectionBehaviorThe collection behavior identifier to set.
Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
-
Indicates whether the window is opaque.
Declaration
Objective-C
- (BOOL)isOpaqueReturn Value
YEStruewhen the window is opaque; otherwise,NOfalse.Discussion
The default is
YEStrue.Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
See Also
-
Specifies whether the window is opaque.
Declaration
Swift
var opaque: BoolObjective-C
@property(getter=isOpaque) BOOL opaqueParameters
opaqueIf
YEStrue, the window is opaque; ifNOfalse, it is not.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Indicates whether the window has a shadow.
Declaration
Swift
var hasShadow: BoolObjective-C
@property BOOL hasShadowReturn Value
YEStruewhen the window has a shadow; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Specifies whether the window has a shadow.
Declaration
Swift
var hasShadow: BoolObjective-C
@property BOOL hasShadowParameters
hasShadowIf
YEStrue, the window has a shadow; ifNOfalse, it does not.Discussion
If the shadow setting changes, the window shadow is invalidated, forcing the window shadow to be recomputed.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Invalidates the window shadow so that it is recomputed based on the current window shape.
Declaration
Swift
func invalidateShadow()Objective-C
- (void)invalidateShadowImport Statement
import AppKitAvailability
Available in OS X v10.2 and later.
See Also
-
Indicates whether the window calculates the thickness of a given border automatically.
Declaration
Swift
func autorecalculatesContentBorderThicknessForEdge(_edge: NSRectEdge) -> BoolObjective-C
- (BOOL)autorecalculatesContentBorderThicknessForEdge:(NSRectEdge)edgeParameters
edgeThe border to check:
NSMaxYEdge: Top border.NSMinYEdge: Bottom border.
Return Value
YEStruewhen the window auto-recalculates the given border’s thickness; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
-
setAutorecalculatesContentBorderThickness(_:forEdge:) setAutorecalculatesContentBorderThickness:forEdge:Specifies whether the window calculates the thickness of a given border automatically.
Declaration
Swift
func setAutorecalculatesContentBorderThickness(_autorecalculateContentBorderThickness: Bool, forEdgeedge: NSRectEdge)Objective-C
- (void)setAutorecalculatesContentBorderThickness:(BOOL)autorecalculateContentBorderThicknessforEdge:(NSRectEdge)edgeParameters
autorecalculateContentBorderThicknessIf
YEStrue, the window calculates the thickness of the edge automatically; ifNOfalse, it does not.edgeThe 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:passingNSMaxYEdgewill 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 callsetAutorecalculatesContentBorderThickness:NO forEdge:.Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
-
Indicates the thickness of a given border of the window.
Declaration
Swift
func contentBorderThicknessForEdge(_edge: NSRectEdge) -> CGFloatObjective-C
- (CGFloat)contentBorderThicknessForEdge:(NSRectEdge)edgeParameters
edgeThe border whose thickness to get:
NSMaxYEdge: Top border.NSMinYEdge: Bottom border.
Return Value
Thickness of the given border, in points.
Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
-
Specifies the thickness of a given border of the window.
Declaration
Swift
func setContentBorderThickness(_borderThickness: CGFloat, forEdgeedge: NSRectEdge)Objective-C
- (void)setContentBorderThickness:(CGFloat)borderThicknessforEdge:(NSRectEdge)edgeParameters
borderThicknessThe thickness for
edge, in points.edgeThe border whose thickness to set:
NSMaxYEdge: Top border.NSMinYEdge: Bottom border.
Discussion
In a nontextured window calling
setContentBorderThickness:forEdge:passingNSMaxYEdgewill 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 callsetAutorecalculatesContentBorderThickness:NO forEdge:.The
contentBorderdoes not include the titlebar or toolbar, so a textured window that just wants the gradient in the titlebar and toolbar should have acontentBorderThicknessof0forNSMaxYEdge.Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
-
Returns the window’s delegate.
Declaration
Swift
unowned(unsafe) var delegate: NSWindowDelegate?Objective-C
@property(assign) id<NSWindowDelegate> delegateReturn Value
The window’s delegate, or
nilif it doesn’t have a delegate.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets the window’s delegate to a given object or removes an existing delegate.
Declaration
Swift
unowned(unsafe) var delegate: NSWindowDelegate?Objective-C
@property(assign) id<NSWindowDelegate> delegateParameters
delegateThe delegate for the window. Pass
nilto remove an existing delegate.Discussion
An
NSWindowobject’s delegate is inserted in the responder chain after the window itself and is informed of various actions by the window through delegation messages.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
– delegate– tryToPerform:with:sendAction:to:from:(NSApplication) -
Indicates whether the window prevents application termination when modal.
Declaration
Swift
var preventsApplicationTerminationWhenModal: BoolObjective-C
@property BOOL preventsApplicationTerminationWhenModalReturn Value
YEStrueif the window prevents application termination when modal; otherwise,NOfalse.Discussion
The default value is
YEStrue.Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
-
Specifies whether the window prevents application termination when modal.
Declaration
Swift
var preventsApplicationTerminationWhenModal: BoolObjective-C
@property BOOL preventsApplicationTerminationWhenModalParameters
flagIf
YEStrue, the window will prevent application termination when modal; ifNOfalse, it will not.Discussion
Normally, 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. Calling this method with an argument of
NOfalseoverrides 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.Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
-
Returns the default depth limit for instances of
NSWindow.Declaration
Swift
class func defaultDepthLimit() -> NSWindowDepthObjective-C
+ (NSWindowDepth)defaultDepthLimitReturn Value
The default depth limit for instances of
NSWindow, determined by the depth of the deepest screen level available to the window server.Discussion
The value returned can be examined with the Application Kit functions
NSPlanarFromDepth,NSColorSpaceFromDepth,NSBitsPerSampleFromDepth, andNSBitsPerPixelFromDepth.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Provides the window number of the window’s window device.
Declaration
Swift
var windowNumber: Int { get }Objective-C
@property(readonly) NSInteger windowNumberReturn Value
The window number of the window’s window device.
Discussion
Each window device in an application is given a unique window number—note that this isn’t the same as the global window number assigned by the window server. This number can be used to identify the window device with the
orderWindow:relativeTo:method and in the Application Kit functionNSWindowList. .If the window doesn’t have a window device, the value returned will be equal to or less than 0.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the window numbers for all visible windows satisfying the specified options.
Declaration
Swift
class func windowNumbersWithOptions(_options: NSWindowNumberListOptions) -> [AnyObject]?Objective-C
+ (NSArray *)windowNumbersWithOptions:(NSWindowNumberListOptions)optionsParameters
optionsThe possible options are specified in
“NSWindowNumberListOptions”.Return Value
An array of window numbers for all visible windows satisfying the specified options. (Windows on the active space are returned in z-order; that is, front to back.)
Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
-
Returns the window’s graphics state object.
Return Value
The graphics state object associated with the window.
Discussion
This graphics state is used by default for all
NSViewobjects in the window’s view hierarchy, but individual views can be made to use their own with theNSViewmethodallocateGState.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
Deprecated in OS X v10.10.
-
canStoreColor() canStoreColor(OS X v10.10)Indicates whether the window has a depth limit that allows it to store color values.
Declaration
Swift
func canStoreColor() -> BoolObjective-C
- (BOOL)canStoreColorReturn Value
YEStruewhen the window’s depth limit allows it to store color values; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
Deprecated in OS X v10.10.
See Also
– depthLimitshouldDrawColor(NSView) -
Returns a dictionary containing information about the window’s resolution.
Declaration
Swift
var deviceDescription: [NSObject : AnyObject] { get }Objective-C
@property(readonly, copy) NSDictionary *deviceDescriptionReturn Value
A dictionary containing resolution information about the window, such as color, depth, and so on.
Discussion
This information is useful for tuning images and colors to the window’s display capabilities. The contents of the dictionary are described in
“Display Device—Descriptions”.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
deviceDescription(NSScreen)bestRepresentationForDevice:(NSImage)colorUsingColorSpaceName:(NSColor) -
Indicates whether the window can be displayed at the login window. Default:
NOfalse.Declaration
Swift
var canBecomeVisibleWithoutLogin: BoolObjective-C
@property BOOL canBecomeVisibleWithoutLoginReturn Value
YEStruewhen the window can be displayed at the login window; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
-
Specifies whether the window can be displayed at the login window.
Declaration
Swift
var canBecomeVisibleWithoutLogin: BoolObjective-C
@property BOOL canBecomeVisibleWithoutLoginParameters
flagYEStrueto allow the window to be displayed at the login window;NOfalseto prevent this behavior.Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
-
Indicates the level of access other processes have to the window’s content.
Declaration
Swift
var sharingType: NSWindowSharingTypeObjective-C
@property NSWindowSharingType sharingTypeReturn Value
The sharing level of the window’s content. See NSWindowSharingType for possible values.
Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
-
Specifies the level of access other processes have to the window’s content.
Declaration
Swift
var sharingType: NSWindowSharingTypeObjective-C
@property NSWindowSharingType sharingTypeParameters
sharingTypeThe sharing level of the window’s content. See NSWindowSharingType for possible values.
Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
-
Returns the window’s backing store type.
Declaration
Swift
var backingType: NSBackingStoreTypeObjective-C
@property NSBackingStoreType backingTypeReturn Value
The backing store type.
Discussion
The possible return values are described in NSBackingStoreType—Buffered Window Drawing.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets the window’s backing store type to a given type.
Declaration
Swift
var backingType: NSBackingStoreTypeObjective-C
@property NSBackingStoreType backingTypeParameters
backingTypeThe backing store type to set.
Discussion
The valid backing store types are described in Constants.
This method can be used only to switch a buffered window to retained or vice versa; you can’t change the backing type to or from nonretained after initializing an
NSWindowobject (an error is generated if you attempt to do so).Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Indicates the window’s backing store location.
Declaration
Swift
var backingLocation: NSWindowBackingLocation { get }Objective-C
@property(readonly) NSWindowBackingLocation backingLocationReturn Value
The location of the window’s backing store. See NSWindowBackingLocation for possible values.
Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
-
Indicates the preferred location for the window’s backing store.
Declaration
Swift
var preferredBackingLocation: NSWindowBackingLocationObjective-C
@property NSWindowBackingLocation preferredBackingLocationReturn Value
The preferred location for the window’s backing store. See Constants for possible values.
Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
-
Specifies the preferred location for the window’s backing store.
Declaration
Swift
var preferredBackingLocation: NSWindowBackingLocationObjective-C
@property NSWindowBackingLocation preferredBackingLocationParameters
preferredBackingLocationThe preferred location for the window’s backing store. See NSWindowBackingLocation for possible values.
Discussion
Use only when optimizing for performance.
Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
-
Indicates whether the window device the window manages is freed when it’s removed from the screen list.
Declaration
Objective-C
- (BOOL)isOneShotReturn Value
YEStruewhen the window’s window device is freed when it’s removed from the screen list; otherwise,NOfalse.Discussion
The default is
NOfalse.Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
See Also
-
Sets whether the window device that the window manages should be freed when it’s removed from the screen list.
Declaration
Swift
var oneShot: BoolObjective-C
@property(getter=isOneShot) BOOL oneShotParameters
oneShotYEStrueto free the window’s window device when it’s removed from the screen list (hidden) and to create another one when it’s returned to the screen;NOfalseto reuse the window device.Discussion
Freeing the window device when it’s removed from the screen list can result in memory savings and performance improvement for
NSWindowobjects that don’t take long to display. It’s particularly appropriate forNSWindowobjects the user might use once or twice but not display continually.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the depth limit of the window.
Return Value
Depth limit of the window.
Discussion
The value returned can be examined with the Application Kit functions
NSPlanarFromDepth,NSColorSpaceFromDepth,NSBitsPerSampleFromDepth, andNSBitsPerPixelFromDepth.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Sets the depth limit of the window to a given limit.
Parameters
depthLimitThe depth limit to set.
Discussion
The
NSBestDepthfunction provides the best depth limit based on a set of parameters.Passing a value of
0fordepthLimitsets the depth limit to the window’s default depth limit. A depth limit of 0 can be useful for reverting anNSWindowobject to its initial depth.On OS X v10.6 and later, you can pass one of the explicit bit depths defined in Explicit Window Depth Limits
NSWindowDepthTwentyfourBitRGBis the default.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Indicates whether the window’s depth limit can change to match the depth of the screen it’s on.
Declaration
Swift
var hasDynamicDepthLimit: Bool { get }Objective-C
@property(readonly) BOOL hasDynamicDepthLimitReturn Value
YEStruewhen the window has a dynamic depth limit; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets whether the window changes its depth to match the depth of the screen it’s on, or the depth of the deepest screen when it spans multiple screens.
Declaration
Swift
func setDynamicDepthLimit(_dynamicDepthLimit: Bool)Objective-C
- (void)setDynamicDepthLimit:(BOOL)dynamicDepthLimitParameters
dynamicDepthLimitIf
YEStrue, the window has a dynamic depth limit; ifNOfalse, it does not.Discussion
When
dynamicDepthLimitisNOfalse, the window uses either its preset depth limit or the default depth limit. A different, and non-dynamic, depth limit can be set with thesetDepthLimit:method.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the content rectangle used by a window with a given frame rectangle and window style.
Declaration
Swift
class func contentRectForFrameRect(_windowFrame: NSRect, styleMaskwindowStyle: Int) -> NSRectObjective-C
+ (NSRect)contentRectForFrameRect:(NSRect)windowFramestyleMask:(NSUInteger)windowStyleParameters
windowFrameThe frame rectangle for the window expressed in screen coordinates.
windowStyleThe window style for the window. See Constants for a list of style mask values.
Return Value
The content rectangle, expressed in screen coordinates, used by the window with
windowFrameandwindowStyle.Discussion
When a
NSWindowinstance is available, you should usecontentRectForFrameRect:instead of this method.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the frame rectangle used by a window with a given content rectangle and window style.
Declaration
Swift
class func frameRectForContentRect(_windowContentRect: NSRect, styleMaskwindowStyle: Int) -> NSRectObjective-C
+ (NSRect)frameRectForContentRect:(NSRect)windowContentRectstyleMask:(NSUInteger)windowStyleParameters
windowContentRectThe content rectangle for a window expressed in screen coordinates.
windowStyleThe window style for the window. See Window Style Masks for a list of style mask values.
Return Value
The frame rectangle, expressed in screen coordinates, used by the window with
windowContentRectandwindowStyle.Discussion
When a
NSWindowinstance is available, you should useframeRectForContentRect:instead of this method.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the minimum width a window’s frame rectangle must have for it to display a title, with a given window style.
Declaration
Swift
class func minFrameWidthWithTitle(_windowTitle: String, styleMaskwindowStyle: Int) -> CGFloatObjective-C
+ (CGFloat)minFrameWidthWithTitle:(NSString *)windowTitlestyleMask:(NSUInteger)windowStyleParameters
windowTitleThe title for the window.
windowStyleThe window style for the window. See Window Style Masks for a list of style mask values.
Return Value
The minimum width of the window’s frame, using
windowStyle, in order to displaywindowTitle.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the window’s content rectangle with a given frame rectangle.
Declaration
Parameters
windowFrameThe frame rectangle for the window expressed in screen coordinates.
Return Value
The window’s content rectangle, expressed in screen coordinates, with
windowFrame.Discussion
The window uses its current style mask in computing the content rectangle. See Window Style Masks for a list of style mask values. The main advantage of this instance-method counterpart to
contentRectForFrameRect:styleMask:is that it allows you to take toolbars into account when converting between content and frame rectangles. (The toolbar is not included in the content rectangle.)Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
-
Returns the window’s frame rectangle with a given content rectangle.
Declaration
Parameters
windowContentThe content rectangle for the window expressed in screen coordinates.
Return Value
The window’s frame rectangle, expressed in screen coordinates, with
windowContent.Discussion
The window uses its current style mask in computing the frame rectangle. See Window Style Masks for a list of style mask values. The major advantage of this instance-method counterpart to
frameRectForContentRect:styleMask:is that it allows you to take toolbars into account when converting between content and frame rectangles. (The toolbar is included in the frame rectangle but not the content rectangle.)Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
-
Returns the collection of drawers associated with the window.
Declaration
Swift
var drawers: [AnyObject]? { get }Objective-C
@property(readonly, copy) NSArray *drawersReturn Value
The collection of drawers associated with the window.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the window’s window controller.
Declaration
Swift
func windowController() -> AnyObject?Objective-C
- (id)windowControllerReturn Value
The window’s window controller.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets the window’s window controller.
Declaration
Swift
func setWindowController(_windowController: NSWindowController?)Objective-C
- (void)setWindowController:(NSWindowController *)windowControllerParameters
windowControllerWindow controller to set.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the sheet attached to the window.
Declaration
Swift
var attachedSheet: NSWindow? { get }Objective-C
@property(readonly, strong) NSWindow *attachedSheetReturn Value
The sheet attached to the window; nil when the window doesn’t have a sheet attached.
Import Statement
import AppKitAvailability
Available in OS X v10.1 and later.
-
Indicates whether the window has ever run as a modal sheet.
Declaration
Objective-C
- (BOOL)isSheetReturn Value
YEStrueif the window has ever run as a modal sheet; otherwise,NOfalse.Import Statement
Availability
Available in OS X v10.1 through OS X v10.9.
-
Starts a document-modal session and presents—or queues for presentation—a sheet.
Declaration
Swift
func beginSheet(_sheetWindow: NSWindow, completionHandlerhandler: ((NSModalResponse) -> Void)?)Objective-C
- (void)beginSheet:(NSWindow *)sheetWindowcompletionHandler:(void (^)(NSModalResponse returnCode))handlerParameters
sheetWindowThe window object that represents the sheet to present.
handlerThe 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.
Import Statement
import AppKitAvailability
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, completionHandlerhandler: ((NSModalResponse) -> Void)?)Objective-C
- (void)beginCriticalSheet:(NSWindow *)sheetWindowcompletionHandler:(void (^)(NSModalResponse returnCode))handlerParameters
sheetWindowThe window object that represents the critical sheet to present. A critical sheet contains content that is time-critical or very important to the user.
handlerThe 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.
Import Statement
import AppKitAvailability
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 *)sheetWindowParameters
sheetWindowThe window object that represents the sheet to be dismissed.
Discussion
This method ends the modal session with the return code
NSModalResponseStop.Import Statement
import AppKitAvailability
Available in OS X v10.9 and later.
-
Ends a document-modal session and dismisses the specified sheet.
Declaration
Swift
func endSheet(_sheetWindow: NSWindow, returnCodereturnCode: NSModalResponse)Objective-C
- (void)endSheet:(NSWindow *)sheetWindowreturnCode:(NSModalResponse)returnCodeParameters
sheetWindowThe window object that represents the sheet to dismiss.
returnCodeThe 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
NSModalResponseenumeration or Additional NSModalResponse Values.Discussion
This method ends the modal session with the specified return code.
Import Statement
import AppKitAvailability
Available in OS X v10.9 and later.
-
Returns the window to which the sheet is attached.
Declaration
Swift
var sheetParent: NSWindow? { get }Objective-C
@property(readonly, strong) NSWindow *sheetParentReturn Value
The window object to which the sheet is attached or
nilif the receiver is not a sheet or has no sheet parent.Discussion
This method returns the window object 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, throughendSheet:).Import Statement
import AppKitAvailability
Available in OS X v10.9 and later.
-
Returns an array of the sheets currently attached to the window.
Declaration
Swift
var sheets: [AnyObject] { get }Objective-C
@property(readonly, copy) NSArray *sheetsReturn Value
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.
Import Statement
import AppKitAvailability
Available in OS X v10.9 and later.
-
Returns the window’s frame rectangle.
Return Value
The frame rectangle of the window in screen coordinates, including the title bar.
Import Statement
import AppKitAvailability
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(_point: NSPoint)Objective-C
- (void)setFrameOrigin:(NSPoint)pointParameters
pointThe 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.
Import Statement
import AppKitAvailability
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(_point: NSPoint)Objective-C
- (void)setFrameTopLeftPoint:(NSPoint)pointParameters
pointThe 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
aPointrelative to the window’s lower-left corner to account for this limit.Import Statement
import AppKitAvailability
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
Parameters
frameRectThe proposed frame rectangle to adjust.
screenThe 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
NSWindowobject 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.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Positions the window's top left to a given point.
Declaration
Parameters
topLeftThe 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 screenReturn 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.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
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(_windowFrame: NSRect, displaydisplayViews: Bool)Objective-C
- (void)setFrame:(NSRect)windowFramedisplay:(BOOL)displayViewsParameters
windowFrameThe frame rectangle for the window, including the title bar.
displayViewsSpecifies whether the window redraws the views that need to be displayed. When
YEStruethe window sends adisplayIfNeededmessage 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.
Import Statement
import AppKitAvailability
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(_windowFrame: NSRect, displaydisplayViews: Bool, animateperformAnimation: Bool)Objective-C
- (void)setFrame:(NSRect)windowFramedisplay:(BOOL)displayViewsanimate:(BOOL)performAnimationParameters
windowFrameThe frame rectangle for the window, including the title bar.
displayViewsSpecifies whether the window redraws the views that need to be displayed. When
YEStruethe window sends adisplayIfNeededmessage down its view hierarchy, thus redrawing all views.performAnimationSpecifies whether the window performs a smooth resize.
YEStrueto perform the animation, whose duration is specified byanimationResizeTime:.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Specifies the duration of a smooth frame-size change.
Declaration
Swift
func animationResizeTime(_newWindowFrame: NSRect) -> NSTimeIntervalObjective-C
- (NSTimeInterval)animationResizeTime:(NSRect)newWindowFrameParameters
newWindowFrameThe 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
NSWindowimplementation uses the value from theNSWindowResizeTimeuser default as the time in seconds to resize by 150 pixels. If this value is unspecified,NSWindowResizeTimeis 0.20 seconds (this default value may be different in different releases of OS X).Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the window’s aspect ratio, which constrains the size of its frame rectangle to integral multiples of this ratio when the user resizes it.
Return Value
The window’s aspect ratio.
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
NSWindowobject’s size to any ratio programmatically.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Sets the window’s aspect ratio, which constrains the size of its frame rectangle to integral multiples of this ratio when the user resizes it.
Parameters
aspectRatioThe aspect ratio to be maintained during resizing actions.
Discussion
An
NSWindowobject’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 anNSWindowobject, you send it asetResizeIncrements:message with the width and height set to1.0:[myWindow setResizeIncrements:NSMakeSize(1.0,1.0)];
The
setContentAspectRatio:method takes precedence over this method.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the minimum size to which the window’s frame (including its title bar) can be sized.
Return Value
The minimum size to which the window’s frame (including its title bar) can be sized either by the user or by the
setFrame...methods other thansetFrame:display:andsetFrame:display:animate:.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Sets the minimum size to which the window’s frame (including its title bar) can be sized to
aSize.Parameters
minFrameSizeThe minimum size of the window’s frame.
Discussion
The minimum size constraint is enforced for resizing by the user as well as for the
setFrame...methods other thansetFrame:display:andsetFrame:display:animate:.The
setContentMinSize:method takes precedence over this method.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the maximum size to which the window’s frame (including its title bar) can be sized.
Return Value
The maximum size to which the window’s frame (including its title bar) can be sized either by the user or by the
setFrame...methods other thansetFrame:display:andsetFrame:display:animate:.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Sets the maximum size to which the window’s frame (including its title bar) can be sized.
Parameters
maxFrameSizeThe maximum size of the window’s frame.
Discussion
The maximum size constraint is enforced for resizing by the user as well as for the
setFrame...methods other thansetFrame:display:andsetFrame: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_MAXis defined in/usr/include/float.h). Once the maximum size of a window has been set, there is no way to reset it other than specifying this default maximum size.The setContentMaxSize: method takes precedence over this method.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns a Boolean value that indicates whether the window is in a zoomed state.
Declaration
Objective-C
- (BOOL)isZoomedReturn Value
YEStrueif the window is in a zoomed state; otherwise,NOfalse.Discussion
The zoomed state of the window is determined using the following steps:
If the delegate or the window class implements
windowWillUseStandardFrame:defaultFrame:, it is invoked to obtain the zoomed frame of the window. The result ofisZoomedis then determined by whether or not the current window frame is equal to the zoomed frame.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 , it is invoked to validate the proposed zoomed frame. Once the zoomed frame is validated, the result ofisZoomedis determined by whether or not the current window frame is equal to the zoomed frame.
Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
See Also
-
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)senderParameters
senderThe 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.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
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)senderParameters
senderThe 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 theperformZoom:method. It performs the following steps: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.Adjusts the resulting frame, if necessary, to fit on the current screen.
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.
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.
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:returnsNOfalseif zooming is not currently allowed.If the window currently allows zooming, sets the new frame.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the flags field of the event record for the mouse-down event that initiated the resizing session.
Declaration
Swift
var resizeFlags: Int { get }Objective-C
@property(readonly) NSInteger resizeFlagsReturn Value
A mask indicating which of the modifier keys was held down when the mouse-down event occurred. The flags are listed in
NSEventobject’smodifierFlagsmethod description.Discussion
This method is valid only while the window is being resized
You can use this method to constrain the direction or amount of resizing. Because of its limited validity, this method should only be invoked from within an implementation of the delegate method
windowWillResize:toSize:.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns a Boolean value that indicates whether the window’s resize indicator is visible.
Declaration
Swift
var showsResizeIndicator: BoolObjective-C
@property BOOL showsResizeIndicatorReturn Value
YEStruewhen the window’s resize indicator is visible; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Specifies whether the window’s resize indicator is visible
Declaration
Swift
var showsResizeIndicator: BoolObjective-C
@property BOOL showsResizeIndicatorParameters
showResizeIndicatorSpecifies the resize indicator state.
YEStrueto show it,NOfalseto hide it.Discussion
This method does not affect whether the window is resizable.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the window’s resizing increments.
Return Value
The window’s resizing increments.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Restricts the user’s ability to resize the window so the width and height change by multiples of width and height increments.
Parameters
resizeIncrementsThe resizing increments to set.
Discussion
As the user resizes the window, its size changes by multiples of
increments.widthandincrements.height, which should be whole numbers, 1.0 or greater. Whatever the current resizing increments, you can set anNSWindowobject’s size to any height and width programmatically.Resize increments and aspect ratio are mutually exclusive attributes. For more information, see
setAspectRatio:.The setContentResizeIncrements: method takes precedence over this method.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns whether the window tries to optimize user-initiated resize operations by preserving the content of views that have not changed.
Declaration
Swift
var preservesContentDuringLiveResize: BoolObjective-C
@property BOOL preservesContentDuringLiveResizeReturn Value
YEStrueif the window tries to optimize live resize operations by preserving the content of views that have not moved; otherwise,NOfalse.Discussion
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.
See
preservesContentDuringLiveResizeinNSViewfor additional information on how to support this optimization.Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
See Also
– setPreservesContentDuringLiveResize:preservesContentDuringLiveResize(NSView) -
Specifies whether the window tries to optimize live resize operations by preserving the content of views that have not changed.
Declaration
Swift
var preservesContentDuringLiveResize: BoolObjective-C
@property BOOL preservesContentDuringLiveResizeParameters
preservesContentDuringLiveResizeYEStrueturns on live-resize optimization;NOfalseturns it off for the window and all of its contained views.Discussion
By default, live-resize optimization is turned on.
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.
Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
See Also
-
Indicates whether the window is being resized by the user.
Declaration
Swift
var inLiveResize: Bool { get }Objective-C
@property(readonly) BOOL inLiveResizeReturn Value
YEStrueif the window is being live resized; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
-
Returns the window’s content aspect ratio.
Return Value
The window’s content aspect ratio.
Discussion
The default content aspect ratio is
(0, 0).Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
See Also
-
Sets the aspect ratio (height in relation to width) of the window’s content view, constraining the dimensions of its content rectangle to integral multiples of that ratio when the user resizes it.
Parameters
contentAspectRatioThe aspect ratio of the window’s content view.
Discussion
You can set a window’s content view to any size programmatically, regardless of its aspect ratio. This method takes precedence over
setAspectRatio:.Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
See Also
-
Returns the minimum size of the window’s content view.
Return Value
The minimum size of the window’s content view.
Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
See Also
-
Sets the minimum size of the window’s content view in the window’s base coordinate system.
Parameters
contentMinSizeThe minimum size of the window’s content view in the window’s base coordinate system.
Discussion
The minimum size constraint is enforced for resizing by the user as well as for the
setContentSize:method and thesetFrame...methods other thansetFrame:display:andsetFrame:display:animate:. This method takes precedence oversetMinSize:.Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
See Also
-
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(_size: NSSize)Objective-C
- (void)setContentSize:(NSSize)sizeParameters
sizeThe 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
NSWindowobject itself. Note that the window server limits window sizes to 10,000; if necessary, be sure to limitaSizerelative to the frame rectangle.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the maximum size of the window’s content view.
Return Value
The maximum size of the window’s content view.
Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
See Also
-
Sets the maximum size of the window’s content view in the window’s base coordinate system.
Parameters
contentMaxSizeThe maximum size of the window’s content view in the window’s base coordinate system.
Discussion
The maximum size constraint is enforced for resizing by the user as well as for the
setContentSize:method and thesetFrame...methods other thansetFrame:display:andsetFrame:display:animate:. This method takes precedence oversetMaxSize:.Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
See Also
-
Returns the window’s content-view resizing increments.
Declaration
Swift
var contentResizeIncrements: NSSizeObjective-C
@property NSSize contentResizeIncrementsReturn Value
The window’s content-view resizing increments.
Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
See Also
-
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.
Declaration
Swift
var contentResizeIncrements: NSSizeObjective-C
@property NSSize contentResizeIncrementsParameters
contentResizeIncrementsThe content-view resizing increments to set.
Discussion
As the user resizes the window, the size of its content view changes by integral multiples of
contentResizeIncrements.widthandcontentResizeIncrements.height. However, you can set a window’s size to any width and height programmatically. This method takes precedence oversetResizeIncrements:.Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
See Also
-
Removes the window from the screen list, which hides the window.
Declaration
Swift
func orderOut(_sender: AnyObject?)Objective-C
- (void)orderOut:(id)senderParameters
senderThe message’s sender.
Discussion
If the window is the key or main window, the
NSWindowobject immediately behind it is made key or main in its place. Calling theorderOut:method causes the window to be removed from the screen, but does not cause it to be released. See theclosemethod 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
setAnimationBehavior:method.Import Statement
import AppKitAvailability
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)senderParameters
senderMessage originator.
Import Statement
import AppKitAvailability
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)senderParameters
senderThe 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
setAnimationBehavior:method.Import Statement
import AppKitAvailability
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)orderFrontRegardlessParameters
senderThe message’s sender.
Discussion
Normally an
NSWindowobject 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.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Repositions the window’s window device in the window server’s screen list.
Declaration
Swift
func orderWindow(_orderingMode: NSWindowOrderingMode, relativeTootherWindowNumber: Int)Objective-C
- (void)orderWindow:(NSWindowOrderingMode)orderingModerelativeTo:(NSInteger)otherWindowNumberParameters
orderingModeNSWindowOut: The window is removed from the screen list andotherWindowNumberis ignored.NSWindowAbove: The window is ordered immediately in front of the window whose window number isotherWindowNumberNSWindowBelow: The window is placed immediately behind the window represented byotherWindowNumber.
otherWindowNumberThe number of the window the window is to be placed in front of or behind. Pass
0to place the window in front of (whenorderingModeisNSWindowAbove) or behind (whenorderingModeisNSWindowBelow) all other windows in its level.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the window level of the window.
Return Value
The window level.
Discussion
See Window Levels for a list of possible values.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets the window’s window level to a given level.
Parameters
windowLevelThe window level to set.
Discussion
Some useful predefined values, ordered from lowest to highest, are described in Window Levels.
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
NSTornOffMenuWindowLevelis preferable to its synonym,NSSubmenuWindowLevel.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Indicates whether the window is visible onscreen (even when It’s obscured by other windows).
Declaration
Objective-C
- (BOOL)isVisibleReturn Value
YEStruewhen the window is onscreen (even if it’s obscured by other windows); otherwise,NOfalse.Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
See Also
visibleRect(NSView) -
Returns the occlusion state of the window.
Declaration
Swift
var occlusionState: NSWindowOcclusionState { get }Objective-C
@property(readonly) NSWindowOcclusionState occlusionStateReturn Value
If
occlusionStateisNSWindowOcclusionStateVisible, at least part of the window is visible; otherwise, the window is fully occluded.Import Statement
import AppKitAvailability
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(_frameName: String)Objective-C
+ (void)removeFrameUsingName:(NSString *)frameNameParameters
frameNameThe name of the frame to remove.
Import Statement
import AppKitAvailability
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(_frameName: String) -> BoolObjective-C
- (BOOL)setFrameUsingName:(NSString *)frameNameParameters
frameNameThe name of the frame to read.
Return Value
YEStruewhenframeNameis 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.Import Statement
import AppKitAvailability
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(_frameName: String, forceforce: Bool) -> BoolObjective-C
- (BOOL)setFrameUsingName:(NSString *)frameNameforce:(BOOL)forceParameters
frameNameThe name of the frame to read.
forceYEStrueto usesetFrameUsingName:on a non-resizable window;NOfalseto fail on a non-resizable window.Return Value
YEStruewhenframeNameis read and the frame is set successfully; otherwise,NOfalse.Import Statement
import AppKitAvailability
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(_frameName: String)Objective-C
- (void)saveFrameUsingName:(NSString *)frameNameParameters
frameNameThe name under which the frame is to be saved.
Discussion
With the companion method
setFrameUsingName:, you can save and reset anNSWindowobject’s frame over various launches of an application. The default is owned by the application and stored under the name"NSWindow FrameframeName". SeeNSUserDefaultsfor more information.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the name used to automatically save the window’s frame rectangle data in the defaults system, as set through
setFrameAutosaveName:.Return Value
The name used to save the window’s frame rectangle automatically in the defaults system.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets the name used to automatically save the window’s frame rectangle in the defaults system to a given name.
Declaration
Swift
func setFrameAutosaveName(_frameName: String) -> BoolObjective-C
- (BOOL)setFrameAutosaveName:(NSString *)frameNameParameters
frameNameThe name under which the frame is to be saved.
Return Value
YEStruewhen the frame name is set successfully;NOfalsewhen frameName is being used as an autosave name by anotherNSWindowobject in the application (in which case the window’s old name remains in effect).Discussion
If
frameNameisn’t the empty string (@""), the window’s frame is saved as a user default (as described insaveFrameUsingName:) each time the frame changes.When the window has an autosave name, its frame data is written whenever the frame rectangle changes.
If there is a frame rectangle previously stored for
frameNamein the user defaults, the window’s frame is set to this frame rectangle. That is, when you call this method with a previously usedframeName, the window picks up the previously saved setting. For example, if you callsetFrameAutosaveName:for a window that is already onscreen, this method could cause the window to move to a different screen location. For this reason, it is generally better to call this method before the window is visible on screen.Keep in mind that a window controller may change the window’s position when it displays it if window cascading is turned on. To preclude the window controller from changing a window’s position from the one saved in the defaults system, you must send
setShouldCascadeWindows:NOto the window controller.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns a string representation of the window’s frame rectangle.
Declaration
Swift
var stringWithSavedFrame: String { get }Objective-C
@property(readonly, copy) NSString *stringWithSavedFrameReturn Value
A string representation of the window’s frame rectangle in a format that can be used with a later
setFrameFromString:message.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Sets the window’s frame rectangle from a given string representation.
Declaration
Swift
func setFrameFromString(_frameString: String)Objective-C
- (void)setFrameFromString:(NSString *)frameStringParameters
frameStringA string representation of a frame rectangle, previously creating 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.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
isKeyWindow isKeyWindowAvailable in OS X v10.0 through OS X v10.9Indicates whether the window is the key window for the application.
Declaration
Objective-C
- (BOOL)isKeyWindowReturn Value
YEStrueif the window is the key window for the application; otherwise,NOfalse.Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
See Also
-
Indicates whether the window can become the key window.
Declaration
Swift
var canBecomeKeyWindow: Bool { get }Objective-C
@property(readonly) BOOL canBecomeKeyWindowReturn Value
YEStrueif the window can become the key window, otherwise,NOfalse.Discussion
Attempts to make the window the key window are abandoned if this method returns
NOfalse. TheNSWindowimplementation returnsYEStrueif the window has a title bar or a resize bar, orNOfalseotherwise.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Makes the window the key window.
Declaration
Swift
func makeKeyWindow()Objective-C
- (void)makeKeyWindowImport Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Moves the window to the front of the screen list, within its level, and makes it the key window; that is, it shows the window.
Declaration
Swift
func makeKeyAndOrderFront(_sender: AnyObject?)Objective-C
- (void)makeKeyAndOrderFront:(id)senderParameters
senderThe message’s sender.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Invoked automatically to inform the window that it has become the key window; never invoke this method directly.
Declaration
Swift
func becomeKeyWindow()Objective-C
- (void)becomeKeyWindowDiscussion
This method reestablishes the window’s first responder, sends the
becomeKeyWindowmessage to that object if it responds, and posts anNSWindowDidBecomeKeyNotificationto the default notification center.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Invoked automatically when the window resigns key window status; never invoke this method directly.
Declaration
Swift
func resignKeyWindow()Objective-C
- (void)resignKeyWindowDiscussion
This method sends
resignKeyWindowto the window’s first responder, sendswindowDidResignKey:to the window’s delegate, and posts anNSWindowDidResignKeyNotificationto the default notification center.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
isMainWindow isMainWindowAvailable in OS X v10.0 through OS X v10.9Indicates whether the window is the application’s main window.
Declaration
Objective-C
- (BOOL)isMainWindowReturn Value
YEStruewhen the window is the main window for the application; otherwise,NOfalse.Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
See Also
-
Indicates whether the window can become the application’s main window.
Declaration
Swift
var canBecomeMainWindow: Bool { get }Objective-C
@property(readonly) BOOL canBecomeMainWindowReturn Value
YEStruewhen the window can become the main window; otherwise,NOfalse.Discussion
Attempts to make the window the main window are abandoned if this method returns
NOfalse. TheNSWindowimplementation returnsYEStrueif the window is visible, is not anNSPanelobject, and has a title bar or a resize mechanism. Otherwise it returnsNOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Makes the window the main window.
Declaration
Swift
func makeMainWindow()Objective-C
- (void)makeMainWindowImport Statement
import AppKitAvailability
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)becomeMainWindowDiscussion
This method posts an
NSWindowDidBecomeMainNotificationto the default notification center.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Invoked automatically when the window resigns main window status; never invoke this method directly.
Declaration
Swift
func resignMainWindow()Objective-C
- (void)resignMainWindowDiscussion
This method sends
windowDidResignMain:to the window’s delegate and posts anNSWindowDidResignMainNotificationto the default notification center.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the window’s toolbar.
Return Value
The window’s toolbar.
Discussion
See the
NSToolbarclass description for additional information.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets the window’s toolbar.
Parameters
toolbarThe toolbar for the window.
Discussion
See the
NSToolbarclass description for additional information.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
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)senderParameters
senderThe message’s sender.
Discussion
See the
NSToolbarclass description for additional information.Import Statement
import AppKitAvailability
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)senderParameters
senderThe message’s sender.
Discussion
See the
NSToolbarclass description for additional information.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns an array of the window’s attached child windows.
Declaration
Swift
var childWindows: [AnyObject]? { get }Objective-C
@property(readonly, copy) NSArray *childWindowsReturn Value
An array containing the window’s child windows.
Import Statement
import AppKitAvailability
Available in OS X v10.2 and later.
-
Adds a given window as a child window of the window.
Declaration
Swift
func addChildWindow(_childWindow: NSWindow, orderedorderingMode: NSWindowOrderingMode)Objective-C
- (void)addChildWindow:(NSWindow *)childWindowordered:(NSWindowOrderingMode)orderingModeParameters
childWindowThe child window to order.
orderingModeNSWindowAbove:childWindowis ordered immediately in front of the window.NSWindowBelow:childWindowis ordered immediately behind the window.
Discussion
After the
childWindowis added as a child of the window, it is maintained in relative position indicated byorderingModefor subsequent ordering operations involving either window. While this attachment is active, movingchildWindowwill not cause the window to move (as in sliding a drawer in or out), but moving the window will causechildWindowto 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.
Import Statement
import AppKitAvailability
Available in OS X v10.2 and later.
-
Detaches a given child window from the window.
Declaration
Swift
func removeChildWindow(_childWindow: NSWindow)Objective-C
- (void)removeChildWindow:(NSWindow *)childWindowParameters
childWindowThe child window to detach.
Import Statement
import AppKitAvailability
Available in OS X v10.2 and later.
-
Returns the parent window to which the window is attached as a child.
Declaration
Swift
unowned(unsafe) var parentWindow: NSWindow?Objective-C
@property(assign) NSWindow *parentWindowReturn Value
The window to which the window is attached as a child.
Import Statement
import AppKitAvailability
Available in OS X v10.2 and later.
-
Adds the window as a child of a given window. For use by subclasses when setting the parent window in the window.
Declaration
Swift
unowned(unsafe) var parentWindow: NSWindow?Objective-C
@property(assign) NSWindow *parentWindowParameters
parentWindowThe window to be a child of the given window.
Discussion
This method should be called from a subclass when it is overridden by a subclass’s implementation. It should not be called otherwise.
Import Statement
import AppKitAvailability
Available in OS X v10.2 and later.
-
isFlushWindowDisabled isFlushWindowDisabledAvailable in OS X v10.0 through OS X v10.9Indicates whether the window’s flushing ability is disabled.
Declaration
Objective-C
- (BOOL)isFlushWindowDisabledReturn Value
YEStruewhen the window’s flushing ability has been disabled; otherwise,NOfalse.Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
-
Reenables the
flushWindowmethod for the window after it was disabled through a previousdisableFlushWindowmessage.Declaration
Swift
func enableFlushWindow()Objective-C
- (void)enableFlushWindowImport Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Disables the
flushWindowmethod for the window.Declaration
Swift
func disableFlushWindow()Objective-C
- (void)disableFlushWindowDiscussion
If the window is buffered, disabling
flushWindowprevents drawing from being automatically flushed by theNSViewdisplay...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
disableFlushWindowmessage must be paired with a subsequentenableFlushWindowmessage. Invocations of these methods can be nested; flushing isn’t reenabled until the lastenableFlushWindowmessage is sent.Import Statement
import AppKitAvailability
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)flushWindowDiscussion
Does nothing for other display devices, such as a printer. This method is automatically invoked by the
NSWindowdisplayanddisplayIfNeededmethods and the correspondingNSViewdisplayanddisplayIfNeededmethods.Import Statement
import AppKitAvailability
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
flushWindowmessage had no effect because flushing was disabled.Declaration
Swift
func flushWindowIfNeeded()Objective-C
- (void)flushWindowIfNeededDiscussion
To avoid unnecessary flushing, use this method rather than
flushWindowto flush anNSWindowobject after flushing has been reenabled.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the button cell that performs as if clicked when the window receives a Return (or Enter) key event.
Declaration
Swift
func defaultButtonCell() -> NSButtonCell?Objective-C
- (NSButtonCell *)defaultButtonCellReturn Value
The button cell.
Discussion
This cell draws itself as the focal element for keyboard interface control, unless another button cell is focused on, in which case the default button cell temporarily draws itself as normal and disables its key equivalent.
The window receives a Return key event if no responder in its responder chain claims it, or if the user presses the Control key along with the Return key.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Makes the key equivalent of button cell the Return (or Enter) key, so when the user presses Return that button performs as if clicked.
Declaration
Swift
func setDefaultButtonCell(_defaultButtonCell: NSButtonCell?)Objective-C
- (void)setDefaultButtonCell:(NSButtonCell *)defaultButtonCellParameters
defaultButtonCellThe button cell to perform as if clicked when the window receives a Return (or Enter) key event.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Reenables the default button cell’s key equivalent, so it performs a click when the user presses Return (or Enter).
Declaration
Swift
func enableKeyEquivalentForDefaultButtonCell()Objective-C
- (void)enableKeyEquivalentForDefaultButtonCellImport Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Disables the default button cell’s key equivalent, so it doesn’t perform a click when the user presses Return (or Enter).
Declaration
Swift
func disableKeyEquivalentForDefaultButtonCell()Objective-C
- (void)disableKeyEquivalentForDefaultButtonCellImport Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the window’s field editor, creating it if requested.
Declaration
Swift
func fieldEditor(_createWhenNeeded: Bool, forObjectanObject: AnyObject?) -> NSText?Objective-C
- (NSText *)fieldEditor:(BOOL)createWhenNeededforObject:(id)anObjectParameters
createWhenNeededIf
YEStrue, creates a field editor if one doesn’t exist; ifNOfalse, does not create a field editor.A freshly created
NSWindowobject doesn’t have a field editor. After a field editor has been created for a window, thecreateWhenNeededargument is ignored. By passingNOfalseforcreateWhenNeededand testing the return value, however, you can predicate an action on the existence of the field editor.anObjectA text-displaying object for which the delegate (in
windowWillReturnFieldEditor:toObject:) assigns a custom field editor. Passnilto get the default field editor, which can be theNSWindowfield editor or a custom field editor returned by the delegate.Return Value
Returns the field editor for the designated object (
anObject) or, ifanObjectisnil, the default field editor. ReturnsnilifcreateFlagisNOfalseand if the field editor doesn’t exist.Discussion
The field editor is a single
NSTextViewobject 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, anNSTextFieldobject 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 dedicatedNSTextViewobject).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 atextDidEndEditing:message to the delegate, you can get its text to display or store and remove the field editor usingendEditingFor:.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 andanObjectas the arguments; if the delegate returns a non-nilvalue, the window returns that object instead of its field editor infieldEditor: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.
Import Statement
import AppKitAvailability
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(_object: AnyObject?)Objective-C
- (void)endEditingFor:(id)objectParameters
objectThe 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
resignFirstRespondermethod returnsNOfalse. This registration forces the field editor to send atextDidEndEditing:message to its delegate. The field editor is then removed from the view hierarchy, its delegate is set tonil, 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. TheendEditingFor: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 theNSWindowobject the first responder:if ([myWindow makeFirstResponder:myWindow]) {/* All fields are now valid; it’s safe to use fieldEditor:forObject:to claim the field editor. */}else {/* Force first responder to resign. */[myWindow endEditingFor:nil];}
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
– fieldEditor:forObject:windowWillReturnFieldEditor:toObject:(NSWindowDelegate)
-
isExcludedFromWindowsMenu isExcludedFromWindowsMenuAvailable in OS X v10.0 through OS X v10.9Indicates whether the window is excluded from the application’s Windows menu.
Declaration
Objective-C
- (BOOL)isExcludedFromWindowsMenuReturn Value
YEStruewhen the window is excluded from the Windows menu; otherwise,NOfalse.Discussion
The default initial setting is
NOfalse.Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
See Also
-
Specifies whether the window’s title is omitted from the application’s Windows menu.
Declaration
Swift
var excludedFromWindowsMenu: BoolObjective-C
@property(getter=isExcludedFromWindowsMenu) BOOL excludedFromWindowsMenuParameters
excludedFromWindowsMenuIf
YEStrue, the window will be omitted from the application’s Windows menu; ifNOfalse, it will not be omitted.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Indicates whether the window’s cursor rectangles are enabled.
Declaration
Swift
var areCursorRectsEnabled: Bool { get }Objective-C
@property(readonly) BOOL areCursorRectsEnabledReturn Value
YEStruewhen cursor rectangles are enabled; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Reenables cursor rectangle management within the window after a
disableCursorRectsmessage.Declaration
Swift
func enableCursorRects()Objective-C
- (void)enableCursorRectsImport Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Disables all cursor rectangle management within the window.
Declaration
Swift
func disableCursorRects()Objective-C
- (void)disableCursorRectsDiscussion
Use this method when you need to do some special cursor manipulation and you don’t want the Application Kit interfering.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Invalidates all cursor rectangles in the window.
Declaration
Swift
func discardCursorRects()Objective-C
- (void)discardCursorRectsDiscussion
This method is invoked by
resetCursorRectsto 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.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Marks as invalid the cursor rectangles of a given
NSViewobject 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(_view: NSView)Objective-C
- (void)invalidateCursorRectsForView:(NSView *)viewParameters
viewThe view in the window’s view hierarchy.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
– resetCursorRectsresetCursorRects(NSView) -
Clears the window’s cursor rectangles and the cursor rectangles of the
NSViewobjects in its view hierarchy.Declaration
Swift
func resetCursorRects()Objective-C
- (void)resetCursorRectsDiscussion
Invokes
discardCursorRectsto clear the window’s cursor rectangles, then sendsresetCursorRectsto everyNSViewobject 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:.Import Statement
import AppKitAvailability
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(_windowButtonKind: NSWindowButton, forStyleMaskwindowStyle: Int) -> NSButton?Objective-C
+ (NSButton *)standardWindowButton:(NSWindowButton)windowButtonKindforStyleMask:(NSUInteger)windowStyleParameters
windowButtonKindThe kind of standard window button to return.
windowStyleThe window style for which
windowButtonKindis 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;nilwhen 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.
Import Statement
import AppKitAvailability
Available in OS X v10.2 and later.
See Also
-
Returns the window button of a given window button kind in the window’s view hierarchy.
Declaration
Swift
func standardWindowButton(_windowButtonKind: NSWindowButton) -> NSButton?Objective-C
- (NSButton *)standardWindowButton:(NSWindowButton)windowButtonKindParameters
windowButtonKindThe kind of standard window button to return.
Return Value
Window button in the window’s view hierarchy of the kind identified by
windowButtonKind;nilwhen such button is not in the window’s view hierarchy.Import Statement
import AppKitAvailability
Available in OS X v10.2 and later.
See Also
-
Indicates whether the toolbar control button is currently displayed.
Declaration
Swift
var showsToolbarButton: BoolObjective-C
@property BOOL showsToolbarButtonReturn Value
YEStrueif the standard toolbar button is currently displayed; otherwise,NOfalse.Discussion
When clicked, the toolbar control button shows or hides a window’s toolbar. The toolbar control button appears in a window’s title bar.
Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
See Also
-
Specifies whether the window shows the toolbar control button.
Declaration
Swift
var showsToolbarButton: BoolObjective-C
@property BOOL showsToolbarButtonParameters
showsToolbarButtonYEStrueto display the toolbar control button;NOfalseto hide the button.Discussion
If the window does not have a toolbar, this method has no effect.
Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
See Also
-
Indicates whether the window can display tooltips even when the application is in the background.
Declaration
Swift
var allowsToolTipsWhenApplicationIsInactive: BoolObjective-C
@property BOOL allowsToolTipsWhenApplicationIsInactiveReturn Value
YEStrueif the window can display tooltips even when the application is in the background; otherwise,NOfalse.Discussion
The default is
NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.3 and later.
-
Specifies whether the window can display tooltips even when the application is in the background.
Declaration
Swift
var allowsToolTipsWhenApplicationIsInactive: BoolObjective-C
@property BOOL allowsToolTipsWhenApplicationIsInactiveParameters
allowTooltipsWhenAppInactiveYEStrueto have the window display tooltips even when its application is inactive;NOfalseto suppress tooltip display when inactive.Import Statement
import AppKitAvailability
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 *)menuParameters
menuThe menu object that changed.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
menu(NSResponder) -
Returns the event currently being processed by the application, by invoking
NSApplication’scurrentEventmethod.Declaration
Swift
var currentEvent: NSEvent? { get }Objective-C
@property(readonly, strong) NSEvent *currentEventReturn Value
The event being processed by the application.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the next event matching a given mask.
Declaration
Objective-C
- (NSEvent *)nextEventMatchingMask:(NSUInteger)eventMaskParameters
eventMaskThe mask that the event to return must match. Events with non-matching masks are left in the queue. See
discardEventsMatchingMask:beforeEvent:inNSApplicationfor the list of mask values.Return Value
The next event whose mask matches
eventMask;nilwhen no matching event was found.Discussion
This method sends the message
nextEventMatchingMask:eventMask untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YESto the application (NSApp).Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
nextEventMatchingMask:untilDate:inMode:dequeue:(NSApplication) -
Forwards the message to the global
NSApplicationobject,NSApp.Declaration
Swift
func nextEventMatchingMask(_eventMask: Int, untilDateexpirationDate: NSDate?, inModerunLoopMode: String, dequeuedequeue: Bool) -> NSEvent?Objective-C
- (NSEvent *)nextEventMatchingMask:(NSUInteger)eventMaskuntilDate:(NSDate *)expirationDateinMode:(NSString *)runLoopModedequeue:(BOOL)dequeueParameters
eventMaskThe mask that the event to return must match.
expirationDateThe date until which to wait for events.
runLoopModeThe run loop mode to use while waiting for events
dequeueYEStrueto remove the returned event from the event queue;NOfalseto leave the returned event in the queue.Return Value
The next event whose mask matches
eventMask;nilwhen no matching event was found.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
nextEventMatchingMask:untilDate:inMode:dequeue:(NSApplication) -
Forwards the message to the
NSApplicationobject,NSApp.Declaration
Objective-C
- (void)discardEventsMatchingMask:(NSUInteger)eventMaskbeforeEvent:(NSEvent *)lastEventParameters
eventMaskThe mask of the events to discard.
lastEventThe event up to which queued events are discarded from the queue.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
discardEventsMatchingMask:beforeEvent:(NSApplication) -
Forwards the message to the global
NSApplicationobject,NSApp.Declaration
Swift
func postEvent(_event: NSEvent, atStartatStart: Bool)Objective-C
- (void)postEvent:(NSEvent *)eventatStart:(BOOL)atStartParameters
eventThe event to add to the window’s event queue.
atStartYEStrueto place the event in the front of the queue;NOfalseto place it in the back.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
This action method dispatches mouse and keyboard events sent to the window by the
NSApplicationobject.Parameters
eventThe 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
NSWindowobject. It is instead delivered to theNSApplicationobject through asendEvent:message with a window number of 0.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Dispatches action messages with a given argument.
Declaration
Swift
func tryToPerform(_selector: Selector, withobject: AnyObject?) -> BoolObjective-C
- (BOOL)tryToPerform:(SEL)selectorwith:(id)objectParameters
selectorThe selector to attempt to execute.
objectThe message’s argument.
Return Value
YEStruewhen the window or its delegate performselectorwithobject; otherwise,NOfalse.Discussion
The window tries to perform the method
selectorusing its inheritedNSRespondermethodtryToPerform:with:. If the window doesn’t performselector, the delegate is given the opportunity to perform it using its inheritedNSObjectmethodperformSelector:withObject:.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns view that’s made first responder the first time the window is placed onscreen.
Declaration
Swift
unowned(unsafe) var initialFirstResponder: NSView?Objective-C
@property(assign) NSView *initialFirstResponderReturn Value
The view that’s made first responder the first time the window is placed onscreen.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the window’s first responder.
Declaration
Swift
var firstResponder: NSResponder { get }Objective-C
@property(readonly, strong) NSResponder *firstResponderReturn Value
The first responder.
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 in that the user selects or activates with the mouse or keyboard.
You can use the
firstRespondermethod 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 in Cocoa Event Handling Guide.“In OS X v10.6 and later,
firstResponderis key-value observing compliant.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
– makeFirstResponder:acceptsFirstResponder(NSResponder) -
Sets a given view as the one 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 *initialFirstResponderParameters
viewThe view to make first responder the first time the window is placed onscreen.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Attempts to make a given responder the first responder for the window.
Declaration
Swift
func makeFirstResponder(_responder: NSResponder?) -> BoolObjective-C
- (BOOL)makeFirstResponder:(NSResponder *)responderParameters
responderThe responder to set as the window’s first responder.
nilmakes the window its first responder.Return Value
YEStruewhen the operation is successful; otherwise,NOfalse.Discussion
If
responderisn’t already the first responder, this method first sends aresignFirstRespondermessage to the object that is the first responder. If that object refuses to resign, it remains the first responder, and this method immediately returnsNOfalse. If the current first responder resigns, this method sends abecomeFirstRespondermessage toresponder. Ifresponderdoes not accept first responder status, theNSWindowobject becomes first responder; in this case, the method returnsYEStrueeven ifresponderrefuses first responder status.If
responderisnil, this method still sendsresignFirstResponderto the current first responder. If the current first responder refuses to resign, it remains the first responder and this method immediately returnsNOfalse. If the current first responder returnsYEStruefromresignFirstResponder, the window is made its own first responder and this method returnsYEStrue.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
responderobject is typically anNSViewobject in the window’s view hierarchy. If this method is called explicitly, first sendacceptsFirstRespondertoresponder, and do not callmakeFirstResponder:ifacceptsFirstResponderreturnsNOfalse.Use
setInitialFirstResponder:to the set the first responder to be used when the window is brought onscreen for the first time.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
becomeFirstResponder(NSResponder)resignFirstResponder(NSResponder)
-
Makes key the view that precedes the given view.
Declaration
Swift
func selectKeyViewPrecedingView(_referenceView: NSView)Objective-C
- (void)selectKeyViewPrecedingView:(NSView *)referenceViewParameters
referenceViewThe view whose preceding view in the key view loop is sought.
Discussion
Sends the
previousValidKeyViewmessage toreferenceViewand, if that message returns anNSViewobject, invokesmakeFirstResponder:with the returned object.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Makes key the view that follows the given view.
Declaration
Swift
func selectKeyViewFollowingView(_referenceView: NSView)Objective-C
- (void)selectKeyViewFollowingView:(NSView *)referenceViewParameters
referenceViewThe view whose following view in the key view loop is sought.
Discussion
Sends the
nextValidKeyViewmessage toreferenceViewand, if that message returns anNSViewobject, invokesmakeFirstResponder:with the returned object.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
This action method searches for a candidate previous key view and, if it finds one, invokes
makeFirstResponder:to establish it as the first responder.Declaration
Swift
func selectPreviousKeyView(_sender: AnyObject?)Objective-C
- (void)selectPreviousKeyView:(id)senderParameters
senderThe message’s sender.
Discussion
The candidate is one of the following (searched for in this order):
The current first responder’s previous valid key view, as returned by the
previousValidKeyViewmethod ofNSViewThe object designated as the window’s initial first responder (using
setInitialFirstResponder:) if it returnsYEStrueto anacceptsFirstRespondermessageOtherwise, the initial first responder’s previous valid key view, which may end up being
nil
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
This action method searches for a candidate next key view and, if it finds one, invokes
makeFirstResponder:to establish it as the first responder.Declaration
Swift
func selectNextKeyView(_sender: AnyObject?)Objective-C
- (void)selectNextKeyView:(id)senderParameters
senderThe message’s sender.
Discussion
The candidate is one of the following (searched for in this order):
The current first responder’s next valid key view, as returned by the
nextValidKeyViewmethod ofNSViewThe object designated as the window’s initial first responder (using
setInitialFirstResponder:) if it returnsYEStrueto anacceptsFirstRespondermessageOtherwise, the initial first responder’s next valid key view, which may end up being
nil
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the direction the window is currently using to change the key view.
Declaration
Swift
var keyViewSelectionDirection: NSSelectionDirection { get }Objective-C
@property(readonly) NSSelectionDirection keyViewSelectionDirectionReturn Value
The direction the window is using to change the key view.
Discussion
This direction can be one of the values described in NSSelectionDirection—Direction of Key View Change.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Indicates whether the window automatically recalculates the key view loop when views are added.
Declaration
Swift
var autorecalculatesKeyViewLoop: BoolObjective-C
@property BOOL autorecalculatesKeyViewLoopReturn Value
YEStrueif the window automatically recalculates the key view loop when views are added; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
-
Marks the key view loop as dirty and in need of recalculation.
Declaration
Swift
func recalculateKeyViewLoop()Objective-C
- (void)recalculateKeyViewLoopDiscussion
The key view loop is actually recalculated the next time someone requests the next or previous key view of the window. The recalculated loop is based on the geometric order of the views in the window.
If you do not want to maintain the key view loop of your window manually, you can use this method to do it for you. When it is first loaded,
NSWindowcalls this method automatically if your window does not have a key view loop already established. If you add or remove views later, you can call this method manually to update the window’s key view loop. You can also callsetAutorecalculatesKeyViewLoop:to have the window recalculate the loop automatically.Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
-
Specifies whether to recalculate the key view loop automatically when views are added or removed.
Declaration
Swift
var autorecalculatesKeyViewLoop: BoolObjective-C
@property BOOL autorecalculatesKeyViewLoopParameters
autorecalculateKeyViewLoopIf
YEStrue,the window recalculates the key view loop automatically; ifNOfalse, it does not.Discussion
If
autorecalculateKeyViewLoopisNOfalse, the client code must update the key view loop manually or callrecalculateKeyViewLoopto have the window recalculate it.Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
-
Handles a given keyboard event that may need to be interpreted as changing the key view or triggering a keyboard equivalent.
Parameters
eventThe keyboard event to process.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
– selectNextKeyView:nextKeyView(NSView)performMnemonic:(NSView)
-
Indicates whether the window accepts mouse-moved events.
Declaration
Swift
var acceptsMouseMovedEvents: BoolObjective-C
@property BOOL acceptsMouseMovedEventsReturn Value
YEStruewhen the window accepts (and distributes) mouse-moved events; otherwise,NOfalse.Discussion
The
NSWindowdefault isNOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Indicates whether the window is transparent to mouse events.
Declaration
Swift
var ignoresMouseEvents: BoolObjective-C
@property BOOL ignoresMouseEventsReturn Value
YEStruewhen the window is transparent to mouse events; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.2 and later.
See Also
-
Specifies whether the window is transparent to mouse clicks and other mouse events, allowing overlay windows.
Declaration
Swift
var ignoresMouseEvents: BoolObjective-C
@property BOOL ignoresMouseEventsParameters
ignoreMouseEventsIf
YEStrue, the window will ignore mouse events; ifNOfalse, it will not.Import Statement
import AppKitAvailability
Available in OS X v10.2 and later.
See Also
-
Returns the current location of the pointer reckoned in the window’s base coordinate system.
Declaration
Swift
var mouseLocationOutsideOfEventStream: NSPoint { get }Objective-C
@property(readonly) NSPoint mouseLocationOutsideOfEventStreamReturn Value
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.
Discussion
For the same information in screen coordinates, use
NSEvent'smouseLocation.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
currentEvent(NSApplication) -
Specifies whether the window is to accept mouse-moved events.
Declaration
Swift
var acceptsMouseMovedEvents: BoolObjective-C
@property BOOL acceptsMouseMovedEventsParameters
acceptMouseMovedEventsYEStrueto have the window accept mouse-moved events (and to distribute them to its responders);NOfalseto not accept such events.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
windowNumberAtPoint(_:belowWindowWithWindowNumber:) windowNumberAtPoint:belowWindowWithWindowNumber:Returns the number of the frontmost window that would be hit by a mouse-down at the specified screen location.
Declaration
Parameters
pointThe location of the mouse-down in screen coordinates.
windowNumberIf non-0, the search will start below
windowNumberwindow 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.
Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
-
Specifies whether the window configuration is preserved between application launches.
Declaration
Swift
var restorable: BoolObjective-C
@property(getter=isRestorable) BOOL restorableParameters
flagSpecify
YEStrueif you want the window to be preserved orNOfalseif you do not want it preserved.Discussion
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
setRestorationClass:method.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
isRestorable isRestorableAvailable in OS X v10.7 through OS X v10.9Returns a Boolean value indicating whether the window configuration is preserved between application launches.
Declaration
Objective-C
- (BOOL)isRestorableReturn Value
YEStrueif the window configuration is preserved orNOfalseif it is not.Discussion
By default, this method returns
YEStrueif the window’sstyleMaskproperty includes theNSTitledWindowMaskflag. For other windows, this method returnsNOfalse. Specifying a value explicitly using thesetRestorable:method overrides the default values.Import Statement
Availability
Available in OS X v10.7 through OS X v10.9.
-
Specifies the class to use to acquire a matching window object during subsequent launches.
Declaration
Swift
var restorationClass: AnyObject.Type?Objective-C
@property(assign) Class<NSWindowRestoration> restorationClassParameters
restorationClassA class object that conforms to the
NSWindowRestorationprotocol. AppKit uses this object to handle the recreation of the window object later.Discussion
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.
If you mark your windows as restorable, you must associate a restoration class with them. For multi-window document applications, AppKit associates the
NSDocumentControllerclass 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.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
Returns the restoration class associated with the window.
Declaration
Swift
var restorationClass: AnyObject.Type?Objective-C
@property(assign) Class<NSWindowRestoration> restorationClassReturn Value
The class object corresponding to the class to use to restore the window or
nilif none is set.Discussion
Restoration classes assist in the recreation of window objects during subsequent launches of the 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.
For multi-window document applications, this method returns the
NSDocumentControllerclass for windows that are associated with anNSDocumentobject by default. For other types of windows, this method returnsnilby default.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
Disable snapshot restoration.
Declaration
Swift
func disableSnapshotRestoration()Objective-C
- (void)disableSnapshotRestorationDiscussion
While snapshot restoration is disabled, the window will not be snapshotted for restorable state.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
Enable snapshot restoration.
Declaration
Swift
func enableSnapshotRestoration()Objective-C
- (void)enableSnapshotRestorationDiscussion
While snapshot restoration is enabled, the window will be snapshotted for restorable state.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
Stores the window’s raster image from a given rectangle expressed in the window’s base coordinate system.
Declaration
Swift
func cacheImageInRect(_rectangle: NSRect)Objective-C
- (void)cacheImageInRect:(NSRect)rectangleParameters
rectangleThe 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
restoreCachedImageandflushWindowIfNeeded. The next time the window displays, it discards its cached image rectangles. You can also explicitly usediscardCachedImageto free the memory occupied by cached image rectangles.aRectis made integral before caching the image to avoid antialiasing artifacts.Only the last cached rectangle is remembered and can be restored.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
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)restoreCachedImageDiscussion
You must invoke
flushWindowafter this method to guarantee proper redisplay. AnNSWindowobject automatically discards its cached image rectangles when it displays.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Discards all of the window’s cached image rectangles.
Declaration
Swift
func discardCachedImage()Objective-C
- (void)discardCachedImageDiscussion
An
NSWindowobject automatically discards its cached image rectangles when it displays.Import Statement
import AppKitAvailability
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)displayDiscussion
You rarely need to invoke this method.
NSWindowobjects normally record which of their views need display and display them automatically on each pass through the event loop.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Passes a
displayIfNeededmessage 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)displayIfNeededDiscussion
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.
NSWindowobjects normally record which of their views need display and display them automatically on each pass through the event loop.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
– displaydisplayIfNeeded(NSView)setNeedsDisplay:(NSView)– isAutodisplay -
Indicates whether any of the window’s views need to be displayed.
Declaration
Swift
var viewsNeedDisplay: BoolObjective-C
@property BOOL viewsNeedDisplayReturn Value
YEStruewhen any of the window’s views need to be displayed; otherwise,NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Specifies whether the window’s views need to be displayed..
Declaration
Swift
var viewsNeedDisplay: BoolObjective-C
@property BOOL viewsNeedDisplayParameters
viewsNeedDisplayIf
YEStrue, the window’s views are set to need to be displayed; ifNOfalse, they are not.Discussion
You should rarely need to invoke this method; the
NSViewmethodsetNeedsDisplay:and similar methods invoke it automatically.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
isAutodisplay isAutodisplayAvailable in OS X v10.0 through OS X v10.9Indicates whether the window automatically displays views that need to be displayed.
Declaration
Objective-C
- (BOOL)isAutodisplayReturn Value
YEStruewhen the window automatically displays views that need to be displayed; otherwise,NOfalse.Discussion
Automatic display typically occurs on each pass through the event loop.
Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
See Also
-
Specifies whether the window is to automatically display the views that are marked as needing it.
Declaration
Swift
var autodisplay: BoolObjective-C
@property(getter=isAutodisplay) BOOL autodisplayParameters
autodisplayIf
YEStrue, the window will automatically display views that need to be displayed; ifNOfalse, it will not.Discussion
If
autodisplayisNOfalse, the window or its views must be explicitly displayed.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
useOptimizedDrawing(_:) useOptimizedDrawing:(OS X v10.10)Specifies whether the window is to optimize focusing and drawing when displaying its views.
Declaration
Swift
func useOptimizedDrawing(_optimizedDrawing: Bool)Objective-C
- (void)useOptimizedDrawing:(BOOL)optimizedDrawingParameters
optimizedDrawingIf
YEStrue, the window will optimize focusing and drawing for its views; ifNOfalse, it will not, in which case, the window does not preserve the Z-ordering of overlapping views when an object explicitly sendslockFocusto 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
optimizedDrawingtoYEStruewhen there are no overlapping subviews within the window. The default isNOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
Deprecated in OS X v10.10.
-
Provides the graphics context associated with the window for the current thread.
Declaration
Swift
var graphicsContext: NSGraphicsContext? { get }Objective-C
@property(readonly, strong) NSGraphicsContext *graphicsContextReturn Value
The graphics context associated with the window for the current thread.
Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
-
Indicates whether the window allows multithreaded view drawing.
Declaration
Swift
var allowsConcurrentViewDrawing: BoolObjective-C
@property BOOL allowsConcurrentViewDrawingReturn Value
YEStrueif the window allows multithreaded view drawing; otherwise,NOfalse.Discussion
The default value is
YEStrue.Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
See Also
-
Specifies whether the window allows its views to be drawn concurrently.
Declaration
Swift
var allowsConcurrentViewDrawing: BoolObjective-C
@property BOOL allowsConcurrentViewDrawingParameters
flagIf
YEStrue, the window allows its views to be drawn concurrently; ifNOfalse, it does not.Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
See Also
-
Returns the window’s automatic animation behavior.
Declaration
Swift
var animationBehavior: NSWindowAnimationBehaviorObjective-C
@property NSWindowAnimationBehavior animationBehaviorReturn Value
The window’s animation behavior. See NSWindowAnimationBehavior for the possible values.
Discussion
This controls the automatic window animation behavior used when a window is sent an
orderFront:ororderOut:message. SeesetAnimationBehavior:for more information.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.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
Sets the window’s automatic animation behavior.
Declaration
Swift
var animationBehavior: NSWindowAnimationBehaviorObjective-C
@property NSWindowAnimationBehavior animationBehaviorParameters
newAnimationBehaviorThe new animation behavior for the window. See NSWindowAnimationBehavior for the possible values.
Discussion
This controls the automatic window animation behavior used when a window is sent an
orderFront:ororderOut:message.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
NSWindowAnimationBehaviorNoneto 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.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
Disables the window’s screen updates until the window is flushed.
Declaration
Swift
func disableScreenUpdatesUntilFlush()Objective-C
- (void)disableScreenUpdatesUntilFlushDiscussion
This method can be invoked to synchronize hardware surface flushes with the window’s flushes. The window immediately disables screen updates using the
NSDisableScreenUpdatesfunction 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 windowdisplayIfNeededordisplay. If it’s unclear whether the window is marked as needing display, you can also ensure that a display occurs by usingsetNeedsDisplayInRect:for a view that’s visible in the window.Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
-
Updates the window.
Declaration
Swift
func update()Objective-C
- (void)updateDiscussion
The
NSWindowimplementation of this method does nothing more than post anNSWindowDidUpdateNotificationnotification to the default notification center. A subclass can override this method to perform specialized operations, but it should send an update message tosuperjust before returning. For example, theNSMenuclass implements this method to disable and enable menu commands.An
NSWindowobject is automatically sent anupdatemessage on every pass through the event loop and before it’s displayed onscreen. You can manually cause anupdatemessage to be sent to all visibleNSWindowobjects through theNSApplicationupdateWindowsmethod.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
setWindowsNeedUpdate:(NSApplication)
-
dragImage(_:at:offset:event:pasteboard:source:slideBack:) dragImage:at:offset:event:pasteboard:source:slideBack:Begins a dragging session.
Declaration
Swift
func dragImage(_image: NSImage, atimageLocation: NSPoint, offsetinitialOffset: NSSize, eventevent: NSEvent, pasteboardpasteboard: NSPasteboard, sourcesourceObject: AnyObject, slideBackslideBack: Bool)Objective-C
- (void)dragImage:(NSImage *)imageat:(NSPoint)imageLocationoffset:(NSSize)initialOffsetevent:(NSEvent *)eventpasteboard:(NSPasteboard *)pasteboardsource:(id)sourceObjectslideBack:(BOOL)slideBackParameters
imageThe object to be dragged.
imageLocationLocation of the image’s bottom-left corner in the window’s coordinate system. It determines the placement of the dragged image under the pointer.
initialOffsetThe pointer’s location relative to the mouse-down location. Not used in OS X v10.4 and later.
eventThe left-mouse down event that triggered the dragging operation.
pasteboardThe pasteboard that holds the data to be transferred to the destination.
sourceObjectThe object serving as the controller of the dragging operation. It must conform to the
NSDraggingSourceprotocol.slideBackSpecifies whether the drag image should slide back to
imageLocationif it's rejected by the drag destination. PassYEStrueto specify slide back behavior orNOfalseto specify that it should not.Discussion
This method should be invoked only from within a view’s implementation of the
mouseDown:ormouseDragged:methods (which overrides the version defined inNSResponderclass). Essentially the same as theNSViewmethod of the same name, except thatimageLocationis given in theNSWindowobject’s base coordinate system.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
dragImage:at:offset:event:pasteboard:source:slideBack:(NSView) -
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(_pasteboardTypes: [AnyObject])Objective-C
- (void)registerForDraggedTypes:(NSArray *)pasteboardTypesParameters
pasteboardTypesAn array of the pasteboard types the window will accept as the destination of an image-dragging session.
Discussion
Registering an
NSWindowobject for dragged types automatically makes it a candidate destination object for a dragging session.NSWindowhas a default implementation for many of the methods in theNSDraggingDestinationprotocol. The default implementation forwards each message to the delegate if the delegate responds to the selector of the message. The messages forwarded this way aredraggingEntered:,draggingUpdated:,draggingExited:,prepareForDragOperation:,performDragOperation:, andconcludeDragOperation:.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Unregisters the window as a possible destination for dragging operations.
Declaration
Swift
func unregisterDraggedTypes()Objective-C
- (void)unregisterDraggedTypesImport Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the backing scale factor.
Declaration
Swift
var backingScaleFactor: CGFloat { get }Objective-C
@property(readonly) CGFloat backingScaleFactorReturn Value
Returns 2.0 for high-resolution scaled display modes, and 1.0 for all other cases.
Discussion
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 this number returned by this method does not represent anything concrete, such as pixel density or physical size, since 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.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Returns a backing store pixel aligned rectangle in window coordinates.
Declaration
Objective-C
- (NSRect)backingAlignedRect:(NSRect)aRectoptions:(NSAlignmentOptions)optionsParameters
aRectThe rectangle in view coordinates.
optionsThe alignment options. See
NSAlignmentOptionsfor 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
NSIntegralRectWithOptionsfunction to produce a backing store pixel aligned rectangle from the given input rectangle in window coordinates.Import Statement
import AppKitAvailability
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
Parameters
aRectThe rect in the pixel backing store aligned coordinate system.
Return Value
A rect in the window’s coordinate system.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
Converts a rectangle from the window’s coordinate system to its pixel aligned backing store coordinate system.
Declaration
Parameters
aRectA rectangle in the window’s coordinate system.
Return Value
A rectangle in its pixel aligned backing store coordinate system.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
Converts the rectangle to the screen coordinate system from the window’s coordinate system.
Declaration
Parameters
aRectA rectangle in the window’s coordinate system.
Return Value
A rectangle in the screen’s coordinate system.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
Converts the rectangle from the screen coordinate system to the window’s coordinate system
Declaration
Parameters
aRectA rectangle in the screen’s coordinate system.
Return Value
A rectangle in the window’s coordinate system.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
convertBaseToScreen: convertBaseToScreen:(OS X v10.7)Converts a given point from the window’s base coordinate system to the screen coordinate system.
Deprecation Statement
Use
convertRectToScreen:instead.Parameters
pointThe point expressed in the window’s base coordinate system.
Return Value
pointexpressed in screen coordinates.Import Statement
Availability
Available in OS X v10.0 and later.
Deprecated in OS X v10.7.
See Also
-
convertScreenToBase: convertScreenToBase:(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.Parameters
pointThe point expressed in screen coordinates.
Return Value
pointexpressed in the window’s base coordinate system.Import Statement
Availability
Available in OS X v10.0 and later.
Deprecated in OS X v10.7.
See Also
-
userSpaceScaleFactor userSpaceScaleFactor(OS X v10.7)Returns the scale factor applied to the window.
Deprecation Statement
Use
convertRectToBacking:andbackingScaleFactorinstead.Declaration
Objective-C
- (CGFloat)userSpaceScaleFactorReturn 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.
Import Statement
Availability
Available in OS X v10.4 and later.
Deprecated in OS X v10.7.
-
isDocumentEdited isDocumentEditedAvailable in OS X v10.0 through OS X v10.9Indicates whether the window’s document has been edited.
Declaration
Objective-C
- (BOOL)isDocumentEditedReturn Value
YEStruewhen the window’s document has been edited; otherwise,NOfalse.Discussion
Initially, by default,
NSWindowobjects are in the “not edited” state.Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
-
Specifies whether the window’s document has been edited.
Declaration
Swift
var documentEdited: BoolObjective-C
@property(getter=isDocumentEdited) BOOL documentEditedParameters
documentEditedIf
YEStrue, the window’s document is marked as having been edited; ifNOfalse, it is marked as not having been edited.Discussion
You should send
setDocumentEdited:YESto anNSWindowobject 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 sendsetDocumentEdited:NO. Then, before closing the window you can useisDocumentEditedto determine whether to allow the user a chance to save the document.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns either the string that appears in the title bar of the window, or the path to the represented file.
Return Value
The window’s title or the path to the represented file.
Discussion
If the title has been set using
setTitleWithRepresentedFilename:, this method returns the file’s path.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets the string that appears in the window’s title bar (if it has one) to a given string and displays the title.
Parameters
titleThe string to set as the window’s title.
Discussion
Also sets the title of the window’s miniaturized window.
Import Statement
import AppKitAvailability
Available in OS X v10.0 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
setRepresentedFilename:.Declaration
Swift
func setTitleWithRepresentedFilename(_filePath: String)Objective-C
- (void)setTitleWithRepresentedFilename:(NSString *)filePathParameters
filePathThe file path to set as the window’s title.
Discussion
The filename—not the pathname—is displayed in the window’s title bar.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns the pathname of the file the window represents.
Declaration
Swift
var representedFilename: StringObjective-C
@property(copy) NSString *representedFilenameReturn Value
The path to the file of the window’s represented file.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Sets the pathname of the file the window represents.
Declaration
Swift
var representedFilename: StringObjective-C
@property(copy) NSString *representedFilenameParameters
filePathThe path to the file to set as the window’s represented file.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Provides the URL of the file the window represents.
Declaration
Swift
@NSCopying var representedURL: NSURL?Objective-C
@property(copy) NSURL *representedURLReturn Value
The URL for the file the window represents.
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:
[[<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:.Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
– setRepresentedURL:window:shouldDragDocumentWithEvent:from:withPasteboard:(NSWindowDelegate) -
Specifies the URL of the file the window represents.
Declaration
Swift
@NSCopying var representedURL: NSURL?Objective-C
@property(copy) NSURL *representedURLParameters
representedURLThe URL of the file the window is to represent.
Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
See Also
-
Returns the screen the window is on.
Declaration
Swift
var screen: NSScreen? { get }Objective-C
@property(readonly, strong) NSScreen *screenReturn Value
The screen where most of the window is on;
nilwhen the window is offscreen.Discussion
When the window is partly on one screen and partly on another, the screen where most of it lies is returned.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the deepest screen the window is on (it may be split over several screens).
Declaration
Swift
var deepestScreen: NSScreen? { get }Objective-C
@property(readonly, strong) NSScreen *deepestScreenReturn Value
The deepest screen the window is on;
nilwhen the window is offscreen.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
– screendeepestScreen(NSScreen) -
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: BoolObjective-C
@property BOOL displaysWhenScreenProfileChangesReturn Value
YEStruewhen the window context should be updated when the screen profile changes or when the window moves to a different screen; otherwise,NOfalse.Discussion
The default value is
NOfalse.Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
-
Specifies whether the window context should be updated when the screen profile changes.
Declaration
Swift
var displaysWhenScreenProfileChanges: BoolObjective-C
@property BOOL displaysWhenScreenProfileChangesParameters
displaysWhenScreenProfileChangesYEStruespecifies that the window context should be changed in these situations:A majority of the window is moved to a different screen whose profile is different than the previous screen.
The ColorSync profile of the current screen changes.
NOfalsespecifies that the screen profile information for the window context doesn’t change.
Discussion
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
NSWindowDidChangeScreenProfileNotificationnotification.Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
See Also
-
isMovableByWindowBackground isMovableByWindowBackgroundAvailable in OS X v10.2 through OS X v10.9Indicates whether the window is movable by clicking and dragging anywhere in its background.
Declaration
Objective-C
- (BOOL)isMovableByWindowBackgroundReturn Value
YEStruewhen the window is movable by clicking and dragging anywhere in its background; otherwise,NOfalse.Discussion
A window with a style mask of
NSTexturedBackgroundWindowMaskis movable by background by default. Sheets and drawers cannot be movable by window background.Import Statement
Availability
Available in OS X v10.2 through OS X v10.9.
See Also
-
Sets whether the window is movable by clicking and dragging anywhere in its background.
Declaration
Swift
var movableByWindowBackground: BoolObjective-C
@property(getter=isMovableByWindowBackground) BOOL movableByWindowBackgroundParameters
movableByWindowBackgroundYEStrueto specify that the window is movable by background,NOfalseto specify that the window is not movable by background.Import Statement
import AppKitAvailability
Available in OS X v10.2 and later.
See Also
-
Indicates whether the window can be moved by clicking in its title bar or background.
Declaration
Objective-C
- (BOOL)isMovableReturn Value
YEStrueif the window can be moved by the user; otherwise,NOfalse.Discussion
setMovableByWindowBackground:, called with the argumentYEStrue, is ignored by a window that returnsNOfalsefromisMovable. If a window returnsNOfalse, that means it 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 non-movable 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 themouseDown:/mouseDragged:/mouseUp:sequence insendEvent:in anNSWindowsubclass.Import Statement
Availability
Available in OS X v10.6 through OS X v10.9.
See Also
-
Specifies whether the window can be dragged by clicking in its title bar or background.
Declaration
Swift
var movable: BoolObjective-C
@property(getter=isMovable) BOOL movableParameters
flagIf
YEStrue, dragging is enabled; ifNOfalse, it is disabled.Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
See Also
-
Sets the window’s location to the center of the screen.
Declaration
Swift
func center()Objective-C
- (void)centerDiscussion
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 theNSApplicationclass.Import Statement
import AppKitAvailability
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)senderParameters
senderThe 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 theNSWindowobject implement the method, only the delegate receives the message.) If thewindowShouldClose:method returnsNOfalse, the window isn’t closed. If it returnsYEStrue, or if it isn’t implemented,performClose:invokes theclosemethod to close the window.If the window doesn’t have a close button or can’t be closed (for example, if the delegate replies
NOfalseto awindowShouldClose:message), the system emits the alert sound.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Removes the window from the screen.
Declaration
Swift
func close()Objective-C
- (void)closeDiscussion
If the window is set to be released when closed, a
releasemessage is sent to the object after the current event is completed. For anNSWindowobject, the default is to be released on closing, while for anNSPanelobject, the default is not to be released. You can use thesetReleasedWhenClosed:method 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
NSWindowWillCloseNotificationnotification 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.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
isReleasedWhenClosed isReleasedWhenClosedAvailable in OS X v10.0 through OS X v10.9Indicates whether the window is released when it receives the
closemessage.Declaration
Objective-C
- (BOOL)isReleasedWhenClosedReturn Value
YEStrueif the window is automatically released after being closed;NOfalseif it’s simply removed from the screen.Discussion
The default for
NSWindowisYEStrue; the default forNSPanelisNOfalse. Release when closed, however, is ignored for windows owned by window controllers.Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
See Also
-
Specifies whether the window is released when it receives the
closemessage.Declaration
Swift
var releasedWhenClosed: BoolObjective-C
@property(getter=isReleasedWhenClosed) BOOL releasedWhenClosedParameters
releasedWhenClosedYEStrueto specify that the window is to be hidden and released when it receives a close message;NOfalseto specify that the window is only hidden, not released.Discussion
Another strategy for releasing an
NSWindowobject is to have its delegate autorelease it on receiving awindowShouldClose:message.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
isMiniaturized isMiniaturizedAvailable in OS X v10.0 through OS X v10.9Indicates whether the window is minimized.
Declaration
Objective-C
- (BOOL)isMiniaturizedReturn Value
YEStrueif the window is minimized; otherwise,NOfalse.Discussion
A minimized window is removed from the screen and replaced by a image, icon, or button that represents it, called the counterpart.
Import Statement
Availability
Available in OS X v10.0 through OS X v10.9.
See Also
-
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)senderParameters
senderThe 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.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
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)senderParameters
senderThe message’s sender.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
De-minimizes the window.
Declaration
Swift
func deminiaturize(_sender: AnyObject?)Objective-C
- (void)deminiaturize:(id)senderParameters
senderThe message’s sender.
Discussion
Invoke this method to programmatically deminimize a minimized window in the Dock.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the custom miniaturized window image of the window.
Declaration
Swift
var miniwindowImage: NSImage?Objective-C
@property(strong) NSImage *miniwindowImageReturn Value
The custom miniaturized window image.
Discussion
The miniaturized window image is the image displayed in the Dock when the window is minimized. If you did not assign a custom image to the window, this method returns
nil.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Sets the window’s custom minimized window image to a given image.
Declaration
Swift
var miniwindowImage: NSImage?Objective-C
@property(strong) NSImage *miniwindowImageParameters
miniwindowImageImage to set as the window’s minimized window image.
Discussion
When the user minimizes the window, the Dock displays
miniwindowImagein the corresponding Dock tile, scaling it as needed to fit in the tile. If you do not specify a custom image using this method, the Dock creates one for you automatically.You can also call this method as needed to change the minimized window image. Typically, you would specify a custom image immediately prior to a window being minimized—when the system posts an
NSWindowWillMiniaturizeNotification. You can call this method while the window is minimized to update the current image in the Dock. However, this method is not recommended for creating complex animations in the Dock.Support for custom images is disabled by default. To enable support, set the
AppleDockIconEnabledkey toYEStruewhen first registering your application’s user defaults. You must set this key prior to calling theinitmethod ofNSApplication, which reads the current value of the key.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the title displayed in the window’s minimized window.
Declaration
Swift
var miniwindowTitle: String!Objective-C
@property(copy) NSString *miniwindowTitleReturn Value
The title displayed in the window’s minimized window.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Sets the title of the window’s miniaturized counterpart to a given string and redisplays it.
Declaration
Swift
var miniwindowTitle: String!Objective-C
@property(copy) NSString *miniwindowTitleParameters
miniwindowTitleThe string to set as the title of the minimized window.
Discussion
A minimized window’s title normally reflects that of its full-size counterpart, abbreviated to fit if necessary. Although this method allows you to set the minimized window’s title explicitly, changing the full-size
NSWindowobject’s title (throughsetTitle:orsetTitleWithRepresentedFilename:) automatically changes the minimized window’s title as well.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Provides the application’s Dock tile.
Declaration
Swift
var dockTile: NSDockTile { get }Objective-C
@property(readonly, strong) NSDockTile *dockTileReturn Value
The application’s Dock tile.
Import Statement
import AppKitAvailability
Available in OS X v10.5 and later.
-
This action method runs the Print panel, and if the user chooses an option other than canceling, prints the window (its frame view and all subviews).
Declaration
Swift
func print(_sender: AnyObject?)Objective-C
- (void)print:(id)senderParameters
senderThe message’s sender.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Returns EPS data that draws the region of the window within a given rectangle.
Declaration
Parameters
rectA rectangle (expressed in the window’s coordinate system) that identifies the region to be expressed as EPS data.
Return Value
The region in the window (identified by
rect) as EPS data.Discussion
This data can be placed on a pasteboard, written to a file, or used to create an
NSImageobject.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
dataWithEPSInsideRect:(NSView)writeEPSInsideRect:toPasteboard:(NSView) -
Returns PDF data that draws the region of the window within a given rectangle.
Declaration
Parameters
rectA rectangle (expressed in the window’s coordinate system) that identifies the region to be expressed as PDF data.
Return Value
The region in the window (identified by
rect) as PDF data.Discussion
This data can be placed on a pasteboard, written to a file, or used to create an
NSImageobject.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
dataWithPDFInsideRect:(NSView)writePDFInsideRect:toPasteboard:(NSView)
-
Searches for an object that responds to a Services request.
Declaration
Parameters
sendTypeThe input type of the Services request.
returnTypeThe return type of the Services request.
Return Value
The object that responds to the services request;
nilwhen none is found.Discussion
Messages to perform this method are initiated by the Services menu. It’s part of the mechanism that passes
validRequestorForSendType:returnType:messages up the responder chain.This method works by forwarding the message to the window’s delegate if it responds (and provided it isn’t an
NSResponderobject with its own next responder). If the delegate doesn’t respond to the message or returnsnilwhen sent it, this method forwards the message to theNSApplicationobject. If theNSApplicationobject returnsnil, this method also returnsnil. Otherwise this method returns the object returned by the delegate or theNSApplicationobject.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
validRequestorForSendType:returnType:(NSResponder)validRequestorForSendType:returnType:(NSApplication)
-
Returns a Cocoa window created from a Carbon window.
Declaration
Swift
convenience init?(windowRefcarbonWindowRef: UnsafeMutablePointer<Void>)Objective-C
- (NSWindow *)initWithWindowRef:(void *)carbonWindowRefParameters
carbonWindowRefThe Carbon
WindowRefobject to use to create the Cocoa window.Return Value
A Cocoa window created from
carbonWindowRef.Discussion
For more information on Carbon-Cocoa integration, see Using a Carbon User Interface in a Cocoa Application in Carbon-Cocoa Integration Guide.
Special Considerations
For historical reasons, contrary to normal memory management policy
initWithWindowRef:does not retainwindowRef. It is therefore recommended that you make sure you retainwindowRefbefore calling this method. IfwindowRefis still valid when the Cocoa window is deallocated, the Cocoa window will release it.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Returns the Carbon
WindowRefassociated with the window, creating one if necessary.Declaration
Swift
var windowRef: UnsafeMutablePointer<Void> { get }Objective-C
@property(readonly) void *windowRefDiscussion
This method can be used to create a
WindowReffor a window containing a Carbon control. Subsequent calls to this method return the existingWindowRef. You use aWindowRefto create a Carbon window reference for a Cocoa window; this assists the integration of Carbon and Cocoa code and objects.For more information see
MacWindows.h. For more information on Carbon-Cocoa integration, see Carbon-Cocoa Integration Guide.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
See Also
-
Updates the constraints based on changes to views in the window since the last layout.
Declaration
Swift
func updateConstraintsIfNeeded()Objective-C
- (void)updateConstraintsIfNeededDiscussion
Whenever a new layout pass is triggered for a window, the system invokes this method to ensure that any constraints for views in the window are updated with information from the current view hierarchy and its constraints. This method is called automatically by the system, but may be invoked manually if you need to examine the most up to date constraints.
Subclasses should not override this method.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Updates the layout of views in the window based on the current views and constraints.
Declaration
Swift
func layoutIfNeeded()Objective-C
- (void)layoutIfNeededDiscussion
Before displaying a window that uses constraints-based layout the system invokes this method to ensure that the layout of all views is up to date. This method updates the layout if needed, first invoking
updateConstraintsIfNeededto ensure that all constraints are up to date. This method is called automatically by the system, but may be invoked manually if you need to examine the most up to date layout.Subclasses should not override this method.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Displays a visual representation of the supplied constraints in the window.
Declaration
Swift
func visualizeConstraints(_constraints: [AnyObject])Objective-C
- (void)visualizeConstraints:(NSArray *)constraintsParameters
constraintsThe constraints to visualize. All constraints must be held by views in the window.
Discussion
The constraints to visualize are typically discovered by identifying a view whose layout is unexpected and then calling
constraintsAffectingLayoutForOrientation:on that view.This method should only be used for debugging constraint-based layout. No application should ship with calls to this method as part of its operation.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Returns which part of the window stays stationary during constraint based layout.
Declaration
Swift
func anchorAttributeForOrientation(_orientation: NSLayoutConstraintOrientation) -> NSLayoutAttributeObjective-C
- (NSLayoutAttribute)anchorAttributeForOrientation:(NSLayoutConstraintOrientation)orientationParameters
orientationThe attribute for orientation. The possible values are specified in
NSLayoutConstraintOrientation.Return Value
Returns the layout attribute.
Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
-
Sets which part of the window stays stationary during constrain based layout.
Declaration
Swift
func setAnchorAttribute(_attr: NSLayoutAttribute, forOrientationorientation: NSLayoutConstraintOrientation)Objective-C
- (void)setAnchorAttribute:(NSLayoutAttribute)attrforOrientation:(NSLayoutConstraintOrientation)orientationParameters
attrThe layout attribute. The possible values are specified in
NSLayoutAttribute.orientationThe window drag orientation. The possible values are specified in
NSLayoutConstraintOrientation.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
See Also
Data Types
-
This type represents the depth, or amount of memory, devoted to a single pixel in a window or screen. A depth of 0 indicates default depth. Window depths should not be made persistent as they will not be the same across systems.
Declaration
Swift
typealias NSWindowDepth = Int32Objective-C
typedef int NSWindowDepth;Discussion
Use the functions
NSColorSpaceFromDepth,NSBitsPerPixelFromDepth, andNSPlanarFromDepthto extract info from anNSWindowDepthvalue. UseNSBestDepthto compute window depths.NSBestDepthtries to accommodate all the parameters (match or better); if there are multiple matches, it gives the closest, with matching color space first, then bps, then planar, thenbpp.bppis “bits per pixel”; 0 indicates default (same as the number of bits per plane, eitherbpsorbps*NSNumberOfColorComponents); other values maybe used as hints to provide backing stores of different configuration: for instance, 8-bit color.On OS X v10.6 and later, you can pass one of the explicit bit depths defined in Explicit Window Depth Limits to the NSWindow method
setDepthLimit:.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
These constants specify the presence of a title and various buttons in a window’s border. It can be
NSBorderlessWindowMask, or it can contain any of the following options, combined using the C bitwise OR operator:Declaration
Swift
var NSBorderlessWindowMask: Int { get } var NSTitledWindowMask: Int { get } var NSClosableWindowMask: Int { get } var NSMiniaturizableWindowMask: Int { get } var NSResizableWindowMask: Int { get } var NSTexturedBackgroundWindowMask: Int { get }Objective-C
enum { NSBorderlessWindowMask = 0, NSTitledWindowMask = 1 << 0, NSClosableWindowMask = 1 << 1, NSMiniaturizableWindowMask = 1 << 2, NSResizableWindowMask = 1 << 3, NSTexturedBackgroundWindowMask = 1 << 8 };Constants
-
NSBorderlessWindowMaskNSBorderlessWindowMaskThe window displays none of the usual peripheral elements. Useful only for display or caching purposes. A window that uses
NSBorderlessWindowMaskcan’t become key or main, unless you implementcanBecomeKeyWindoworcanBecomeMainWindowto returnYEStrue. Note that you can set a window’s or panel’s style mask toNSBorderlessWindowMaskin Interface Builder by deselecting Title Bar in the Appearance section of the Attributes inspector.Available in OS X v10.0 and later.
-
NSTitledWindowMaskNSTitledWindowMaskThe window displays a title bar.
Available in OS X v10.0 and later.
-
NSClosableWindowMaskNSClosableWindowMaskThe window displays a close button.
Available in OS X v10.0 and later.
-
NSMiniaturizableWindowMaskNSMiniaturizableWindowMaskThe window displays a minimize button.
Available in OS X v10.0 and later.
-
NSResizableWindowMaskNSResizableWindowMaskThe window displays a resize control.
Available in OS X v10.0 and later.
-
NSTexturedBackgroundWindowMaskNSTexturedBackgroundWindowMaskThe window displays with a metal-textured background. Additionally, the window may be moved by clicking and dragging anywhere in the window background. A bordered window with this mask gets rounded bottom corners.
Available in OS X v10.2 and later.
Import Statement
-
-
The standard window levels in OS X.
Declaration
Objective-C
#define NSNormalWindowLevel kCGNormalWindowLevel #define NSFloatingWindowLevel kCGFloatingWindowLevel #define NSSubmenuWindowLevel kCGTornOffMenuWindowLevel #define NSTornOffMenuWindowLevel kCGTornOffMenuWindowLevel #define NSMainMenuWindowLevel kCGMainMenuWindowLevel #define NSStatusWindowLevel kCGStatusWindowLevel #define NSModalPanelWindowLevel kCGModalPanelWindowLevel #define NSPopUpMenuWindowLevel kCGPopUpMenuWindowLevel #define NSScreenSaverWindowLevel kCGScreenSaverWindowLevel #define NSDockWindowLevel kCGDockWindowLevelConstants
-
NSNormalWindowLevelNSNormalWindowLevelThe default level for
NSWindowobjects.Available in OS X v10.0 and later.
-
NSFloatingWindowLevelNSFloatingWindowLevelUseful for floating palettes.
Available in OS X v10.0 and later.
-
NSSubmenuWindowLevelNSSubmenuWindowLevelReserved for submenus. Synonymous with
NSTornOffMenuWindowLevel, which is preferred.Available in OS X v10.0 and later.
-
NSTornOffMenuWindowLevelNSTornOffMenuWindowLevelThe level for a torn-off menu. Synonymous with
NSSubmenuWindowLevel.Available in OS X v10.0 and later.
-
NSModalPanelWindowLevelNSModalPanelWindowLevelThe level for a modal panel.
Available in OS X v10.0 and later.
-
NSMainMenuWindowLevelNSMainMenuWindowLevelReserved for the application’s main menu.
Available in OS X v10.0 and later.
-
NSStatusWindowLevelNSStatusWindowLevelThe level for a status window.
Available in OS X v10.0 and later.
-
NSPopUpMenuWindowLevelNSPopUpMenuWindowLevelThe level for a pop-up menu.
Available in OS X v10.0 and later.
-
NSScreenSaverWindowLevelNSScreenSaverWindowLevelThe level for a screen saver.
Available in OS X v10.0 and later.
-
NSDockWindowLevelNSDockWindowLevelThe level for the dock.
Deprecated. There is no replacement.
Available in OS X v10.0 and later.
Discussion
The stacking of levels takes precedence over the stacking of windows within each level. That is, even the bottom window in a level will obscure the top window of the next level down. Levels are listed in order from lowest to highest. These constants are mapped (using
#definestatements) to corresponding elements inWindow Level Keys.Import Statement
-
-
These constants are the keys for device description dictionaries used by
deviceDescription.Declaration
Swift
var NSDeviceResolution: NSString! var NSDeviceColorSpaceName: NSString! var NSDeviceBitsPerSample: NSString! var NSDeviceIsScreen: NSString! var NSDeviceIsPrinter: NSString! var NSDeviceSize: NSString!Objective-C
NSString *NSDeviceResolution; NSString *NSDeviceColorSpaceName; NSString *NSDeviceBitsPerSample; NSString *NSDeviceIsScreen; NSString *NSDeviceIsPrinter; NSString *NSDeviceSize;Constants
-
NSDeviceResolutionNSDeviceResolutionThe corresponding value is an
NSValueobject containing a value of typeNSSizethat describes the window’s raster resolution in dots per inch (dpi).Available in OS X v10.0 and later.
-
NSDeviceColorSpaceNameNSDeviceColorSpaceNameThe corresponding value is an
NSStringobject giving the name of the window’s color space.See
Color Space Namesin AppKit Constants Reference for a list of possible values.Available in OS X v10.0 and later.
-
NSDeviceBitsPerSampleNSDeviceBitsPerSampleThe corresponding value is an
NSNumberobject containing an integer that gives the bit depth of the window’s raster image (2-bit, 8-bit, and so forth).Available in OS X v10.0 and later.
-
NSDeviceIsScreenNSDeviceIsScreenIf there is a corresponding value, this indicates that the display device is a screen.
Available in OS X v10.0 and later.
-
NSDeviceIsPrinterNSDeviceIsPrinterIf there is a corresponding value, this indicates that the display device is a printer.
Available in OS X v10.0 and later.
-
NSDeviceSizeNSDeviceSizeThe corresponding value is an
NSValueobject containing a value of typeNSSizethat gives the size of the window’s frame rectangle.Available in OS X v10.0 and later.
Import Statement
-
-
Manages scaling factors.
This constant no longer has an effect because the scale factor for a window backing store is dynamic and dependent on the screen on which the window is placed.
Declaration
Swift
var NSUnscaledWindowMask: Int { get }Objective-C
enum { NSUnscaledWindowMask = 1 << 11 };Constants
-
NSUnscaledWindowMaskNSUnscaledWindowMaskSpecifies that the window is created without any scaling factors applied.
The client is responsible for all scaling operations in the window. Such a window returns
1.0from itsuserSpaceScaleFactormethod.Currently restricted to borderless windows (
NSBorderlessWindowMask).Available in OS X v10.0 and later.
Deprecated in OS X v10.9.
Import Statement
-
-
This constant controls the look of a window and its toolbar.
Declaration
Swift
var NSUnifiedTitleAndToolbarWindowMask: Int { get }Objective-C
enum { NSUnifiedTitleAndToolbarWindowMask = 1 << 12 };Constants
-
NSUnifiedTitleAndToolbarWindowMaskNSUnifiedTitleAndToolbarWindowMaskSpecifies a window whose toolbar and title bar are rendered on a single continuous background.
Available in OS X v10.4 and later.
Import Statement
-
-
This constant indicates that a window is in fullscreen mode.
Declaration
Swift
var NSFullScreenWindowMask: Int { get }Objective-C
enum { NSFullScreenWindowMask = 1 << 14 };Constants
-
NSFullScreenWindowMaskNSFullScreenWindowMaskIndicates that a window has fullscreen appearance.
A fullscreen window does not draw its titlebar, and may have special handling for its toolbar.
Available in OS X v10.7 and later.
Import Statement
-
-
These constants specify the direction a window is currently using to change the key view. They’re used by
keyViewSelectionDirection.Declaration
Objective-C
enum { NSDirectSelection = 0, NSSelectingNext , NSSelectingPrevious }; typedef NSUInteger NSSelectionDirection;Constants
-
DirectSelectionNSDirectSelectionThe window isn’t traversing the key view loop.
Available in OS X v10.0 and later.
-
SelectingNextNSSelectingNextThe window is proceeding to the next valid key view.
Available in OS X v10.0 and later.
-
SelectingPreviousNSSelectingPreviousThe window is proceeding to the previous valid key view.
Available in OS X v10.0 and later.
Import Statement
Availability
Available in OS X v10.0 and later.
-
-
These constants provide a way to access standard title bar buttons:
Declaration
Objective-C
enum { NSWindowCloseButton , NSWindowMiniaturizeButton , NSWindowZoomButton , NSWindowToolbarButton , NSWindowDocumentIconButton , NSWindowDocumentVersionsButton = 6, NSWindowFullScreenButton , }; typedef NSUInteger NSWindowButton;Constants
-
CloseButtonNSWindowCloseButtonThe close button.
Available in OS X v10.2 and later.
-
MiniaturizeButtonNSWindowMiniaturizeButtonThe minimize button.
Available in OS X v10.2 and later.
-
ZoomButtonNSWindowZoomButtonThe zoom button.
Available in OS X v10.2 and later.
-
ToolbarButtonNSWindowToolbarButtonThe toolbar button.
Available in OS X v10.2 and later.
-
DocumentIconButtonNSWindowDocumentIconButtonThe document icon button.
Available in OS X v10.2 and later.
-
DocumentVersionsButtonNSWindowDocumentVersionsButtonThe document versions button.
Available in OS X v10.7 and later.
-
FullScreenButtonNSWindowFullScreenButtonThe fullscreen icon button.
Available in OS X v10.7 and later.
Import Statement
Availability
Available in OS X v10.2 and later.
-
-
These constants are passed to
NSRunLoop'sperformSelector:target:argument:order:modes:.Declaration
Swift
var NSDisplayWindowRunLoopOrdering: Int { get } var NSResetCursorRectsRunLoopOrdering: Int { get }Objective-C
enum { NSDisplayWindowRunLoopOrdering , NSResetCursorRectsRunLoopOrdering };Constants
-
NSDisplayWindowRunLoopOrderingNSDisplayWindowRunLoopOrderingThe priority at which windows are displayed.
Available in OS X v10.0 and later.
-
NSResetCursorRectsRunLoopOrderingNSResetCursorRectsRunLoopOrderingThe priority at which cursor rects are reset.
Available in OS X v10.0 and later.
Import Statement
-
-
These constants define explicit window depths that can be used with
setDepthLimit:.Declaration
Swift
var NSWindowDepthTwentyfourBitRGB: Int { get } var NSWindowDepthSixtyfourBitRGB: Int { get } var NSWindowDepthOnehundredtwentyeightBitRGB: Int { get }Objective-C
enum { NSWindowDepthTwentyfourBitRGB = 0x208 , NSWindowDepthSixtyfourBitRGB = 0x210 , NSWindowDepthOnehundredtwentyeightBitRGB = 0x220 };Constants
-
NSWindowDepthTwentyfourBitRGBNSWindowDepthTwentyfourBitRGBTwenty four bit RGB depth limit.
Available in OS X v10.6 and later.
-
NSWindowDepthSixtyfourBitRGBNSWindowDepthSixtyfourBitRGBSixty four bit RGB depth limit.
Available in OS X v10.6 and later.
-
NSWindowDepthOnehundredtwentyeightBitRGBNSWindowDepthOnehundredtwentyeightBitRGBOne hundred and twenty eight bit RGB depth limit.
Available in OS X v10.6 and later.
Import Statement
-
-
These constants specify how the drawing done in a window is buffered by the window device.
Declaration
Objective-C
enum { NSBackingStoreRetained = 0, NSBackingStoreNonretained = 1, NSBackingStoreBuffered = 2 }; typedef NSUInteger NSBackingStoreType;Constants
-
RetainedNSBackingStoreRetainedThe window uses a buffer, but draws directly to the screen where possible and to the buffer for obscured portions.
You should not use this mode. It combines the limitations of
NSBackingStoreNonretainedwith the memory use ofNSBackingStoreBuffered. The original NeXTSTEP implementation was an interesting compromise that worked well with fast memory mapped framebuffers on the CPU bus—something that hasn't been in general use since around 1994. These tend to have performance problems.In OS X v10.5 and later, requests for retained windows will result in the window system creating a buffered window, as that better matches actual use.
Available in OS X v10.0 and later.
-
NonretainedNSBackingStoreNonretainedThe window draws directly to the screen without using any buffer.
You should not use this mode. It exists primarily for use in the original Classic Blue Box. It does not support Quartz drawing, alpha blending, or opacity. Moreover, it does not support hardware acceleration, and interferes with system-wide display acceleration. If you use this mode, your application must manage visibility region clipping itself, and manage repainting on visibility changes.
Available in OS X v10.0 and later.
-
BufferedNSBackingStoreBufferedThe window renders all drawing into a display buffer and then flushes it to the screen.
You should use this mode. It supports hardware acceleration, Quartz drawing, and takes advantage of the GPU when possible. It also supports alpha channel drawing, opacity controls, using the compositor.
Available in OS X v10.0 and later.
Import Statement
Availability
Available in OS X v10.0 and later.
-
-
These constants let you specify how a window is ordered relative to another window. For more information, see
orderWindow:relativeTo:.Declaration
Objective-C
enum { NSWindowAbove = 1, NSWindowBelow = -1, NSWindowOut = 0 }; typedef NSInteger NSWindowOrderingMode;Constants
-
AboveNSWindowAboveMoves the window above the indicated window.
Available in OS X v10.0 and later.
-
BelowNSWindowBelowMoves the window below the indicated window.
Available in OS X v10.0 and later.
-
OutNSWindowOutMoves the window off the screen.
Available in OS X v10.0 and later.
Import Statement
Availability
Available in OS X v10.0 and later.
-
-
The following constants and the related data type represent the access levels other processes can have to a window’s content.
Declaration
Objective-C
enum { NSWindowSharingNone = 0, NSWindowSharingReadOnly = 1, NSWindowSharingReadWrite = 2 }; typedef NSUInteger NSWindowSharingType;Constants
-
NoneNSWindowSharingNoneThe window’s contents cannot be read by another process.
Available in OS X v10.5 and later.
-
ReadOnlyNSWindowSharingReadOnlyThe window’s contents can be read but not modified by another process.
Available in OS X v10.5 and later.
-
ReadWriteNSWindowSharingReadWriteThe window’s contents can be read and modified by another process.
Available in OS X v10.5 and later.
Import Statement
Availability
Available in OS X v10.5 and later.
-
-
The following constants and the related data type represent a window’s possible backing locations.
Declaration
Objective-C
enum { NSWindowBackingLocationDefault = 0, NSWindowBackingLocationVideoMemory = 1, NSWindowBackingLocationMainMemory = 2 }; typedef NSUInteger NSWindowBackingLocation;Constants
-
DefaultNSWindowBackingLocationDefaultDetermined by the operating system.
Available in OS X v10.5 and later.
-
VideoMemoryNSWindowBackingLocationVideoMemoryVideo memory.
Available in OS X v10.5 and later.
-
MainMemoryNSWindowBackingLocationMainMemoryPhysical memory.
Available in OS X v10.5 and later.
Import Statement
Availability
Available in OS X v10.5 and later.
-
-
The options that may be passed to the
windowNumbersWithOptions:method.Declaration
Swift
typealias NSWindowNumberListOptions = IntObjective-C
enum { NSWindowNumberListAllApplications = 1 << 0, NSWindowNumberListAllSpaces = 1 << 4 }; typedef NSUInteger NSWindowNumberListOptions;Constants
-
NSWindowNumberListAllApplicationsNSWindowNumberListAllApplicationsThe window numbers of windows visible on any space and belonging to any application.
Available in OS X v10.6 and later.
-
NSWindowNumberListAllSpacesNSWindowNumberListAllSpacesThe window numbers of windows visible on any space and belonging to the calling application.
Available in OS X v10.6 and later.
Discussion
If the value 0 is passed instead, then the list returned from the method contains window numbers for visible windows on the active space belonging to the calling application.
Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
-
-
These constants control the automatic window animation behavior used when a window is sent an
orderFront:ororderOut:message.Declaration
Objective-C
enum { NSWindowAnimationBehaviorDefault = 0, NSWindowAnimationBehaviorNone = 2, NSWindowAnimationBehaviorDocumentWindow = 3, NSWindowAnimationBehaviorUtilityWindow = 4, NSWindowAnimationBehaviorAlertPanel = 5 }; typedef NSInteger NSWindowAnimationBehavior;Constants
-
DefaultNSWindowAnimationBehaviorDefaultThe automatic animation that’s appropriate to the window type. This is the default.
Available in OS X v10.7 and later.
-
NoneNSWindowAnimationBehaviorNoneNo automatic animation used. This may be useful when you perform your own window animation.
Available in OS X v10.7 and later.
-
DocumentWindowNSWindowAnimationBehaviorDocumentWindowThe animation behavior that’s appropriate to the document window style.
Available in OS X v10.7 and later.
-
UtilityWindowNSWindowAnimationBehaviorUtilityWindowThe animation behavior that’s appropriate to the utility window style.
Available in OS X v10.7 and later.
-
AlertPanelNSWindowAnimationBehaviorAlertPanelThe animation behavior that’s appropriate to the alert window style.
Available in OS X v10.7 and later.
Import Statement
Availability
Available in OS X v10.7 and later.
-
-
Window collection behaviors related to Exposé and Spaces.
Declaration
Objective-C
enum { NSWindowCollectionBehaviorDefault = 0, NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0, NSWindowCollectionBehaviorMoveToActiveSpace = 1 << 1 }; enum { NSWindowCollectionBehaviorManaged = 1 << 2, NSWindowCollectionBehaviorTransient = 1 << 3, NSWindowCollectionBehaviorStationary = 1 << 4, }; enum { NSWindowCollectionBehaviorParticipatesInCycle = 1 << 5, NSWindowCollectionBehaviorIgnoresCycle = 1 << 6 }; enum { NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7, NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8 }; typedef NSUInteger NSWindowCollectionBehavior;Constants
-
DefaultNSWindowCollectionBehaviorDefaultThe window can be associated to one space at a time.
Available in OS X v10.5 and later.
-
CanJoinAllSpacesNSWindowCollectionBehaviorCanJoinAllSpacesThe window appears in all spaces. The menu bar behaves this way.
Available in OS X v10.5 and later.
-
MoveToActiveSpaceNSWindowCollectionBehaviorMoveToActiveSpaceMaking the window active does not cause a space switch; the window switches to the active space.
Available in OS X v10.5 and later.
-
ManagedNSWindowCollectionBehaviorManagedThe window participates in Spaces and Exposé. This is the default behavior if
windowLevelis equal toNSNormalWindowLevel.Available in OS X v10.6 and later.
-
TransientNSWindowCollectionBehaviorTransientThe window floats in Spaces and is hidden by Exposé. This is the default behavior if
windowLevelis not equal toNSNormalWindowLevel.Available in OS X v10.6 and later.
-
StationaryNSWindowCollectionBehaviorStationaryThe window is unaffected by Exposé; it stays visible and stationary, like the desktop window.
Available in OS X v10.6 and later.
-
ParticipatesInCycleNSWindowCollectionBehaviorParticipatesInCycleThe window participates in the window cycle for use with the Cycle Through Windows Window menu item.
Available in OS X v10.6 and later.
-
IgnoresCycleNSWindowCollectionBehaviorIgnoresCycleThe window is not part of the window cycle for use with the Cycle Through Windows Window menu item.
Available in OS X v10.6 and later.
-
FullScreenPrimaryNSWindowCollectionBehaviorFullScreenPrimaryA window with this collection behavior has a fullscreen button in the upper right of its titlebar.
Available in OS X v10.7 and later.
-
FullScreenAuxiliaryNSWindowCollectionBehaviorFullScreenAuxiliaryWindows with this collection behavior can be shown on the same space as the fullscreen window.
Available in OS X v10.7 and later.
Import Statement
Availability
Available in OS X v10.5 and later.
-
-
Specifies whether the window is occluded.
Declaration
Objective-C
enum { NSWindowOcclusionStateVisible = 1UL << 1, }; typedef NSUInteger NSWindowOcclusionState;Constants
-
VisibleNSWindowOcclusionStateVisibleIf set, at least part of the window is visible; if not set, the entire window is occluded. A window that has a nonrectangular shape can be entirely occluded onscreen, but if its bounding box falls into a visible region, the window is considered to be visible. Note that a completely transparent window may also be considered visible.
Available in OS X v10.9 and later.
Import Statement
Availability
Available in OS X v10.9 and later.
-
-
These constants specify values that can be returned by
endSheet:and by the completion handlers forbeginSheet:completionHandler:andbeginCriticalSheet:completionHandler:.Declaration
Objective-C
enum { NSModalResponseOK = 1, NSModalResponseCancel = 0 };Constants
-
NSModalResponseOKNSModalResponseOKThe presentation or dismissal of the sheet has finished.
Available in OS X v10.9 and later.
-
NSModalResponseCancelNSModalResponseCancelThe presentation or dismissal of the sheet has been canceled.
Available in OS X v10.9 and later.
Import Statement
-
-
The version of the AppKit.framework containing a specific bug fix or capability.
Declaration
Swift
var NSAppKitVersionNumberWithDeferredWindowDisplaySupport: Double { get }Objective-C
#define NSAppKitVersionNumberWithDeferredWindowDisplaySupport 1019.0Constants
-
NSAppKitVersionNumberWithDeferredWindowDisplaySupportNSAppKitVersionNumberWithDeferredWindowDisplaySupportThe specific version of the AppKit framework that introduced support for deferred window display. Developers should not need to use this constant unless they are writing applications for OS X v10.5 and earlier.
Available in OS X v10.6 and later.
Import Statement
-
-
The version of the AppKit.framework containing a specific bug fix or capability.
Declaration
Swift
var NSAppKitVersionNumberWithCustomSheetPosition: Double { get }Objective-C
#define NSAppKitVersionNumberWithCustomSheetPosition 686.0Constants
-
NSAppKitVersionNumberWithCustomSheetPositionNSAppKitVersionNumberWithCustomSheetPositionThe specific version of the AppKit framework that introduced custom sheet positioning. Developers should not need to use this constant unless they are writing applications for OS X v10.2 and earlier.
Available in OS X v10.3 and later.
Import Statement
-
-
These constants are values that are returned in the
userInfodictionary of theNSWindowDidChangeBackingPropertiesNotification.Declaration
Swift
let NSBackingPropertyOldScaleFactorKey: NSString! let NSBackingPropertyOldColorSpaceKey: NSString!Objective-C
NSString * const NSBackingPropertyOldScaleFactorKey ; NSString * const NSBackingPropertyOldColorSpaceKey;Constants
-
NSBackingPropertyOldScaleFactorKeyNSBackingPropertyOldScaleFactorKeyAn NSNumber containing the old scale factor.
Available in OS X v10.7 and later.
-
NSBackingPropertyOldColorSpaceKeyNSBackingPropertyOldColorSpaceKeyAn NSColorSpace instance containing the old colorspace.
Available in OS X v10.7 and later.
Import Statement
-
-
Posted whenever an
NSWindowobject becomes the key window.The notification object is the
NSWindowobject that has become key. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever an
NSWindowobject becomes the main window.The notification object is the
NSWindowobject that has become main. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever a portion of an
NSWindowobject’s frame moves onto or off of a screen.The notification object is the
NSWindowobject that has changed screens. This notification does not contain auserInfodictionary.This notification is not sent in OS X versions earlier than 10.4.
Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever the display profile for the screen containing the window changes.
This notification is sent only if the window returns
YEStruefromdisplaysWhenScreenProfileChanges. This notification may be sent when a majority of the window is moved to a different screen (whose profile is also different from the previous screen) or when the ColorSync profile for the current screen changes.The notification object is the
NSWindowobject whose profile changed. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.4 and later.
-
Posted whenever an
NSWindowobject is deminimized.The notification object is the
NSWindowobject that has been deminimized. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever an
NSWindowobject closes an attached sheet.The notification object is the
NSWindowobject that contained the sheet. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.1 and later.
-
Posted after the user resizes a window.
This notification is sent only once for a series of window resize operations.
The notification object is the
NSWindowobject that was resized. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
-
Posted whenever a portion of a nonretained
NSWindowobject is exposed, whether by being ordered in front of other windows or by other windows being removed from in front of it.The notification object is the
NSWindowobject that has been exposed. TheuserInfodictionary contains the following information:Key
Value
@"NSExposedRect"The rectangle that has been exposed (an
NSValueobject containing an NSRect).Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever an
NSWindowobject is minimized.The notification object is the
NSWindowobject that has been minimized. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever an
NSWindowobject resigns its status as key window.The notification object is the
NSWindowobject that has resigned its key window status. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever an
NSWindowobject resigns its status as main window.The notification object is the
NSWindowobject that has resigned its main window status. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever an
NSWindowobject’s size changes.The notification object is the
NSWindowobject whose size has changed. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever an
NSWindowobject is about to open a sheet.The notification object is the
NSWindowobject that is about to open the sheet. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.1 and later.
-
Posted whenever an
NSWindowobject is about to close.The notification object is the
NSWindowobject that is about to close. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever an
NSWindowobject is about to be minimized.The notification object is the
NSWindowobject that is about to be minimized. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted whenever an
NSWindowobject is about to move.The notification object is the
NSWindowobject that is about to move. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.0 and later.
-
Posted before the user resizes a window.
This notification is sent only once for a series of window resize operations.
The notification object is the
NSWindowobject that is about to be live resized. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.6 and later.
-
Posted when the window will enter full screen mode.
The notification object is the
NSWindowobject will enter full screen mode. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Posted when the window entered full screen mode.
The notification object is the
NSWindowobject entered full screen mode. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Posted when the window will exit full screen mode.
The notification object is the
NSWindowobject that will exit full screen mode. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Posted when the window did exit full screen mode.
The notification object is the
NSWindowobject that will exit full screen mode. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Posted when the window will enter version browser mode.
The notification object is the
NSWindowobject that will enter version browser mode. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Posted when the window will enter version browser mode.
The notification object is the
NSWindowobject that will enter version browser mode. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Posted when the window will exit version browser mode.
The notification object is the
NSWindowobject that will exit version browser mode. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Posted when the window did exit version browser mode.
The notification object is the
NSWindowobject that did exit version browser mode. This notification does not contain auserInfodictionary.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Posted when the window backing properties change.
The notification object is the
NSWindowobject whose backing properties changes. This notification contains auserInfodictionary that has backing scale and color space information. See NSWindowDidChangeBackingPropertiesNotification User Info Properties for theuserInfodictionary keys and values.Import Statement
import AppKitAvailability
Available in OS X v10.7 and later.
-
Posted when the window’s occlusion state changes.
The notification object is the
NSWindowobject whose occlusion state has changed. This notification does not contain auserInfodictionary.This notification indicates a change in the window’s occlusion state; it doesn’t indicate a change in the occlusion region. When you receive this notification, you can get the window’s current occlusion state and—based on the result—you may want to increase responsiveness and save power by halting expensive operations that the user can’t see.
Import Statement
import AppKitAvailability
Available in OS X v10.9 and later.
Copyright © 2014 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2014-02-11
