NSWindow
A window that an app displays on the screen.
Declaration
@MainActor class NSWindowOverview
A single NSWindow object corresponds to, at most, one on-screen window. Windows perform two principal functions:
To place views in a provided area
To accept and distribute mouse and keyboard events the user generates to the appropriate views
Topics
Creating a Window
init(contentViewController:)init(contentRect:styleMask:backing:defer:)init(contentRect:styleMask:backing:defer:screen:)
Managing the Window’s Behavior
Configuring the Window’s Content
Configuring the Window’s Appearance
styleMaskNSWindow.StyleMasktoggleFullScreen(_:)worksWhenModalalphaValuebackgroundColorcolorSpacesetDynamicDepthLimit(_:)canHideisOnActiveSpacehidesOnDeactivatecollectionBehaviorisOpaquehasShadowinvalidateShadow()autorecalculatesContentBorderThickness(for:)setAutorecalculatesContentBorderThickness(_:for:)contentBorderThickness(for:)setContentBorderThickness(_:for:)preventsApplicationTerminationWhenModalappearanceSource
Accessing Window Information
depthLimithasDynamicDepthLimitdefaultDepthLimitwindowNumberwindowNumbers(options:)deviceDescriptionNSDeviceDescriptionKeycanBecomeVisibleWithoutLoginsharingTypebackingTypedisplayLink(target:selector:)
Getting Layout Information
contentRect(forFrameRect:styleMask:)frameRect(forContentRect:styleMask:)minFrameWidth(withTitle:styleMask:)contentRect(forFrameRect:)frameRect(forContentRect:)
Managing Windows
Managing Sheets
attachedSheetisSheetbeginSheet(_:completionHandler:)beginCriticalSheet(_:completionHandler:)endSheet(_:)endSheet(_:returnCode:)sheetParentsheets
Sizing Windows
framesetFrameOrigin(_:)setFrameTopLeftPoint(_:)constrainFrameRect(_:to:)cascadeTopLeft(from:)setFrame(_:display:)setFrame(_:display:animate:)animationResizeTime(_:)aspectRatiominSizemaxSizeisZoomedperformZoom(_:)zoom(_:)resizeFlagsresizeIncrementspreservesContentDuringLiveResizeinLiveResize
Sizing Content
contentAspectRatiocontentMinSizesetContentSize(_:)contentMaxSizecontentResizeIncrementscontentLayoutGuidecontentLayoutRectmaxFullScreenContentSizeminFullScreenContentSize
Managing Window Layers
orderOut(_:)orderBack(_:)orderFront(_:)orderFrontRegardless()order(_:relativeTo:)levelNSWindow.Level
Managing Window Visibility and Occlusion State
Managing Window Frames in User Defaults
removeFrame(usingName:)setFrameUsingName(_:)setFrameUsingName(_:force:)saveFrame(usingName:)setFrameAutosaveName(_:)frameAutosaveNameNSWindow.FrameAutosaveNameframeDescriptorsetFrame(from:)NSWindow.PersistableFrameDescriptor
Managing Key Status
Managing Main Status
Managing Toolbars
Managing Attached Windows
Managing Default Buttons
defaultButtonCellenableKeyEquivalentForDefaultButtonCell()disableKeyEquivalentForDefaultButtonCell()
Managing Field Editors
Managing the Window Menu
Managing Cursor Rectangles
areCursorRectsEnabledenableCursorRects()disableCursorRects()discardCursorRects()invalidateCursorRects(for:)resetCursorRects()
Managing Title Bars
standardWindowButton(_:for:)standardWindowButton(_:)showsToolbarButtontitlebarAppearsTransparenttoolbarStyleNSWindow.ToolbarStyletitlebarSeparatorStyleNSTitlebarSeparatorStylewindowTitlebarLayoutDirection
Managing Title Bar Accessories
addTitlebarAccessoryViewController(_:)insertTitlebarAccessoryViewController(_:at:)removeTitlebarAccessoryViewController(at:)titlebarAccessoryViewControllers
Managing Window Tabs
allowsAutomaticWindowTabbinguserTabbingPreferencetabtabbingIdentifierNSWindow.TabbingIdentifieraddTabbedWindow(_:ordered:)tabbingModetabbedWindowsmergeAllWindows(_:)selectNextTab(_:)selectPreviousTab(_:)moveTabToNewWindow(_:)toggleTabBar(_:)toggleTabOverview(_:)tabGroup
Managing Tooltips
Handling Events
currentEventnextEvent(matching:)nextEvent(matching:until:inMode:dequeue:)discardEvents(matching:before:)postEvent(_:atStart:)sendEvent(_:)tryToPerform(_:with:)
Managing Responders
Managing the Key View Loop
selectKeyView(preceding:)selectKeyView(following:)selectPreviousKeyView(_:)selectNextKeyView(_:)keyViewSelectionDirectionautorecalculatesKeyViewLooprecalculateKeyViewLoop()
Managing Window Sharing
Handling Mouse Events
acceptsMouseMovedEventsignoresMouseEventsmouseLocationOutsideOfEventStreamwindowNumber(at:belowWindowWithWindowNumber:)trackEvents(matching:timeout:mode:handler:)performDrag(with:)foreverDuration
Handling Window Restoration
Drawing Windows
Window Animation
Updating Windows
Dragging Items
drag(_:at:offset:event:pasteboard:source:slideBack:)registerForDraggedTypes(_:)unregisterDraggedTypes()
Accessing Edited Status
Converting Coordinates
backingScaleFactorbackingAlignedRect(_:options:)convertFromBacking(_:)convertFromScreen(_:)convertPointFromBacking(_:)convertPoint(fromScreen:)convertToBacking(_:)convertToScreen(_:)convertPointToBacking(_:)convertPoint(toScreen:)
Managing Titles
Accessing Screen Information
Moving Windows
Closing Windows
Minimizing Windows
Getting the Dock Tile
Printing Windows
Providing Services
Triggering Constraint-Based Layout
Debugging Constraint-Based Layout
Constraint-Based Layouts
Working with Window Depths
Getting Information About Scripting Attributes
Setting Scripting Attributes
Handling Script Commands
Constants
NSWindow.SelectionDirectionNSWindow.ButtonTypeNSRunLoop—Ordering Modes for NSWindowNSWindow.DepthNSWindow.BackingStoreTypeNSWindow.OrderingModeNSWindow.SharingTypeNSWindow.NumberListOptionsNSWindow.AnimationBehaviorNSWindow.CollectionBehaviorNSWindow.OcclusionStateNSWindow.TitleVisibilityNSWindow.UserTabbingPreferenceNSWindow.TabbingModeApplication Kit Version for Deferred Window Display SupportApplication Kit Version for Custom Sheet PositionNSWindowDidChangeBackingPropertiesNotification User Info Properties
Notifications
didBecomeKeyNotificationdidBecomeMainNotificationdidChangeScreenNotificationdidChangeScreenProfileNotificationdidDeminiaturizeNotificationdidEndSheetNotificationdidEndLiveResizeNotificationdidExposeNotificationdidMiniaturizeNotificationdidMoveNotificationdidResignKeyNotificationdidResignMainNotificationdidResizeNotificationdidUpdateNotificationwillBeginSheetNotificationwillCloseNotificationwillMiniaturizeNotificationwillMoveNotificationwillStartLiveResizeNotificationwillEnterFullScreenNotificationdidEnterFullScreenNotificationwillExitFullScreenNotificationdidExitFullScreenNotificationwillEnterVersionBrowserNotificationdidEnterVersionBrowserNotificationwillExitVersionBrowserNotificationdidExitVersionBrowserNotificationdidChangeBackingPropertiesNotificationdidChangeOcclusionStateNotification