Protocol

NSWindowDelegate

The NSWindowDelegate protocol defines the methods that a delegate of NSWindow should implement. All methods in this protocol are optional.

Overview

By implementing these methods, the delegate may respond to window resizing, moving, exposing, minimizing, and a number of other window events.

Symbols

Managing Sheets

func window(NSWindow, willPositionSheet: NSWindow, using: NSRect)

Tells the delegate that the window is about to show a sheet at the specified location, giving it the opportunity to return a custom location for the attachment of the sheet to the window.

func windowWillBeginSheet(Notification)

Notifies the delegate that the window is about to open a sheet.

func windowDidEndSheet(Notification)

Tells the delegate that the window has closed a sheet.

Sizing Windows

func windowWillResize(NSWindow, to: NSSize)

Tells the delegate that the window is being resized (whether by the user or through one of the setFrame... methods other than setFrame(_:display:)).

func windowDidResize(Notification)

Tells the delegate that the window has been resized.

func windowWillStartLiveResize(Notification)

Tells the delegate that the window is about to be live resized.

func windowDidEndLiveResize(Notification)

Tells the delegate that a live resize operation on the window has ended.

Minimizing Windows

func windowWillMiniaturize(Notification)

Tells the delegate that the window is about to be minimized.

func windowDidMiniaturize(Notification)

Tells the delegate that the window has been minimized.

func windowDidDeminiaturize(Notification)

Tells the delegate that the window has been deminimized.

Zooming Window

func windowWillUseStandardFrame(NSWindow, defaultFrame: NSRect)

Called by NSWindow’s zoom(_:) method while determining the frame a window may be zoomed to.

func windowShouldZoom(NSWindow, toFrame: NSRect)

Asks the delegate whether the specified window should zoom to the specified frame.

Managing Full-Screen Presentation

func window(NSWindow, willUseFullScreenContentSize: NSSize)

Called to allow the delegate to modify the full-screen content size.

func window(NSWindow, willUseFullScreenPresentationOptions: NSApplicationPresentationOptions = [])

Returns the presentation options the window uses when transitioning to full-screen mode.

func windowWillEnterFullScreen(Notification)

The window is about to enter full-screen mode.

func windowDidEnterFullScreen(Notification)

The window has entered full-screen mode.

func windowWillExitFullScreen(Notification)

The window is about to exit full-screen mode.

func windowDidExitFullScreen(Notification)

The window has left full-screen mode.

Custom Full-Screen Presentation Animations

func customWindowsToEnterFullScreen(for: NSWindow)

Called when the window is about to enter full-screen mode.

func customWindowsToEnterFullScreen(for: NSWindow, on: NSScreen)

Called when the window is about to enter full-screen mode.

func window(NSWindow, startCustomAnimationToEnterFullScreenWithDuration: TimeInterval)

This method is called to start the window animation into full-screen mode, including transitioning to a new space.

func window(NSWindow, startCustomAnimationToEnterFullScreenOn: NSScreen, withDuration: TimeInterval)

This method is called to start the window animation into full-screen mode, including transitioning to a new space.

func windowDidFailToEnterFullScreen(NSWindow)

Called if the window failed to enter full-screen mode.

func customWindowsToExitFullScreen(for: NSWindow)

Called when the window is about to exit full-screen mode.

func window(NSWindow, startCustomAnimationToExitFullScreenWithDuration: TimeInterval)

This method is called to start the window animation out of full-screen mode, including transitioning back to the desktop space.

func windowDidFailToExitFullScreen(NSWindow)

Called if the window failed to exit full-screen mode.

Moving Windows

func windowWillMove(Notification)

Tells the delegate that the window is about to move.

func windowDidMove(Notification)

Tells the delegate that the window has moved.

func windowDidChangeScreen(Notification)

Tells the delegate that the window has changed screens.

func windowDidChangeScreenProfile(Notification)

Tells the delegate that the window has changed screen display profiles.

func windowDidChangeBackingProperties(Notification)

Tells the delegate that the window backing properties changed.

Closing Windows

func windowShouldClose(Any)

Tells the delegate that the user has attempted to close a window or the window has received a performClose(_:) message.

func windowWillClose(Notification)

Tells the delegate that the window is about to close.

Managing Key Status

func windowDidBecomeKey(Notification)

Tells the delegate that the window has become the key window.

func windowDidResignKey(Notification)

Tells the delegate that the window has resigned key window status.

Managing Main Status

func windowDidBecomeMain(Notification)

Tells the delegate that the window has become main.

func windowDidResignMain(Notification)

Tells the delegate that the window has resigned main window status.

Managing Field Editors

func windowWillReturnFieldEditor(NSWindow, to: Any?)

Tells the delegate that the field editor for a text-displaying object has been requested.

Updating Windows

func windowDidUpdate(Notification)

Tells the delegate that the window received an update() message.

Exposing Windows

func windowDidExpose(Notification)

Tells the delegate that the window has been exposed.

Managing Occlusion State

func windowDidChangeOcclusionState(Notification)

Tells the delegate that the window changed its occlusion state.

Dragging Windows

func window(NSWindow, shouldDragDocumentWith: NSEvent, from: NSPoint, with: NSPasteboard)

Asks the delegate whether a user can drag the document icon from the window’s title bar.

Getting the Undo Manager

func windowWillReturnUndoManager(NSWindow)

Tells the delegate that the window’s undo manager has been requested. Returns the appropriate undo manager for the window.

Managing Titles

func window(NSWindow, shouldPopUpDocumentPathMenu: NSMenu)

Asks the delegate whether the window displays the title pop-up menu in response to a Command-click or Control-click on its title.

Managing Restorable State

func window(NSWindow, willEncodeRestorableState: NSCoder)

Tells the delegate the window is about to add its restorable state to a given archiver.

func window(NSWindow, didDecodeRestorableState: NSCoder)

Tells the delegate the window is has extracted its restorable state from a given archiver.

Managing Presentation in Version Browsers

func window(NSWindow, willResizeForVersionBrowserWithMaxPreferredSize: NSSize, maxAllowedSize: NSSize)

Tells the delegate the the window will resize for presentation during version browsing.

func windowWillEnterVersionBrowser(Notification)

Tells the delegate the the window is about to enter version browsing.

func windowDidEnterVersionBrowser(Notification)

Tells the delegate that the window has entered version browsing.

func windowWillExitVersionBrowser(Notification)

Tells the delegate that the window is about to leave version browsing.

func windowDidExitVersionBrowser(Notification)

Tells the delegate that the window has left version browsing.

Relationships

Inherits From