<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindowDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSWindowDelegate"
  },
  "title" : "NSWindowDelegate"
}
-->

# NSWindowDelegate

A set of optional methods that a window’s delegate can implement to respond to events, such as window resizing, moving, exposing, and minimizing.

```
protocol NSWindowDelegate : NSObjectProtocol
```

## Topics

### Managing Sheets

[`window(_:willPositionSheet:using:)`](/documentation/AppKit/NSWindowDelegate/window(_:willPositionSheet:using:))

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.

[`windowWillBeginSheet(_:)`](/documentation/AppKit/NSWindowDelegate/windowWillBeginSheet(_:))

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

[`windowDidEndSheet(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidEndSheet(_:))

Tells the delegate that the window has closed a sheet.

### Sizing Windows

[`windowWillResize(_:to:)`](/documentation/AppKit/NSWindowDelegate/windowWillResize(_:to:))

Tells the delegate that the window is being resized (whether by the user or through one of the `setFrame...` methods other than [`setFrame(_:display:)`](/documentation/AppKit/NSWindow/setFrame(_:display:))).

[`windowDidResize(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidResize(_:))

Tells the delegate that the window has been resized.

[`windowWillStartLiveResize(_:)`](/documentation/AppKit/NSWindowDelegate/windowWillStartLiveResize(_:))

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

[`windowDidEndLiveResize(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidEndLiveResize(_:))

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

### Minimizing Windows

[`windowWillMiniaturize(_:)`](/documentation/AppKit/NSWindowDelegate/windowWillMiniaturize(_:))

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

[`windowDidMiniaturize(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidMiniaturize(_:))

Tells the delegate that the window has been minimized.

[`windowDidDeminiaturize(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidDeminiaturize(_:))

Tells the delegate that the window has been deminimized.

### Zooming Window

[`windowWillUseStandardFrame(_:defaultFrame:)`](/documentation/AppKit/NSWindowDelegate/windowWillUseStandardFrame(_:defaultFrame:))

Called by `NSWindow`’s [`zoom(_:)`](/documentation/AppKit/NSWindow/zoom(_:)) method while determining the frame a window may be zoomed to.

[`windowShouldZoom(_:toFrame:)`](/documentation/AppKit/NSWindowDelegate/windowShouldZoom(_:toFrame:))

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

### Managing Full-Screen Presentation

[`window(_:willUseFullScreenContentSize:)`](/documentation/AppKit/NSWindowDelegate/window(_:willUseFullScreenContentSize:))

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

[`window(_:willUseFullScreenPresentationOptions:)`](/documentation/AppKit/NSWindowDelegate/window(_:willUseFullScreenPresentationOptions:))

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

[`windowWillEnterFullScreen(_:)`](/documentation/AppKit/NSWindowDelegate/windowWillEnterFullScreen(_:))

The window is about to enter full-screen mode.

[`windowDidEnterFullScreen(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidEnterFullScreen(_:))

The window has entered full-screen mode.

[`windowWillExitFullScreen(_:)`](/documentation/AppKit/NSWindowDelegate/windowWillExitFullScreen(_:))

The window is about to exit full-screen mode.

[`windowDidExitFullScreen(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidExitFullScreen(_:))

The window has left full-screen mode.

### Custom Full-Screen Presentation Animations

[`customWindowsToEnterFullScreen(for:)`](/documentation/AppKit/NSWindowDelegate/customWindowsToEnterFullScreen(for:))

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

[`customWindowsToEnterFullScreen(for:on:)`](/documentation/AppKit/NSWindowDelegate/customWindowsToEnterFullScreen(for:on:))

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

[`window(_:startCustomAnimationToEnterFullScreenWithDuration:)`](/documentation/AppKit/NSWindowDelegate/window(_:startCustomAnimationToEnterFullScreenWithDuration:))

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

[`window(_:startCustomAnimationToEnterFullScreenOn:withDuration:)`](/documentation/AppKit/NSWindowDelegate/window(_:startCustomAnimationToEnterFullScreenOn:withDuration:))

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

[`windowDidFailToEnterFullScreen(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidFailToEnterFullScreen(_:))

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

[`customWindowsToExitFullScreen(for:)`](/documentation/AppKit/NSWindowDelegate/customWindowsToExitFullScreen(for:))

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

[`window(_:startCustomAnimationToExitFullScreenWithDuration:)`](/documentation/AppKit/NSWindowDelegate/window(_:startCustomAnimationToExitFullScreenWithDuration:))

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

[`windowDidFailToExitFullScreen(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidFailToExitFullScreen(_:))

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

### Moving Windows

[`windowWillMove(_:)`](/documentation/AppKit/NSWindowDelegate/windowWillMove(_:))

Tells the delegate that the window is about to move.

[`windowDidMove(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidMove(_:))

Tells the delegate that the window has moved.

[`windowDidChangeScreen(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidChangeScreen(_:))

Tells the delegate that the window has changed screens.

[`windowDidChangeScreenProfile(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidChangeScreenProfile(_:))

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

[`windowDidChangeBackingProperties(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidChangeBackingProperties(_:))

Tells the delegate that the window backing properties changed.

### Closing Windows

[`windowShouldClose(_:)`](/documentation/AppKit/NSWindowDelegate/windowShouldClose(_:))

Tells the delegate that the user has attempted to close a window or the window has received a [`performClose(_:)`](/documentation/AppKit/NSWindow/performClose(_:)) message.

[`windowWillClose(_:)`](/documentation/AppKit/NSWindowDelegate/windowWillClose(_:))

Tells the delegate that the window is about to close.

### Managing Key Status

[`windowDidBecomeKey(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidBecomeKey(_:))

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

[`windowDidResignKey(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidResignKey(_:))

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

### Managing Main Status

[`windowDidBecomeMain(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidBecomeMain(_:))

Tells the delegate that the window has become main.

[`windowDidResignMain(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidResignMain(_:))

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

### Managing Field Editors

[`windowWillReturnFieldEditor(_:to:)`](/documentation/AppKit/NSWindowDelegate/windowWillReturnFieldEditor(_:to:))

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

### Updating Windows

[`windowDidUpdate(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidUpdate(_:))

Tells the delegate that the window received an [`update()`](/documentation/AppKit/NSWindow/update()) message.

### Exposing Windows

[`windowDidExpose(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidExpose(_:))

Tells the delegate that the window has been exposed.

### Managing Occlusion State

[`windowDidChangeOcclusionState(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidChangeOcclusionState(_:))

Tells the delegate that the window changed its occlusion state.

### Dragging Windows

[`window(_:shouldDragDocumentWith:from:with:)`](/documentation/AppKit/NSWindowDelegate/window(_:shouldDragDocumentWith:from:with:))

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

### Getting the Undo Manager

[`windowWillReturnUndoManager(_:)`](/documentation/AppKit/NSWindowDelegate/windowWillReturnUndoManager(_:))

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

### Managing Titles

[`window(_:shouldPopUpDocumentPathMenu:)`](/documentation/AppKit/NSWindowDelegate/window(_:shouldPopUpDocumentPathMenu:))

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

[`window(_:willEncodeRestorableState:)`](/documentation/AppKit/NSWindowDelegate/window(_:willEncodeRestorableState:))

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

[`window(_:didDecodeRestorableState:)`](/documentation/AppKit/NSWindowDelegate/window(_:didDecodeRestorableState:))

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

### Managing Presentation in Version Browsers

[`window(_:willResizeForVersionBrowserWithMaxPreferredSize:maxAllowedSize:)`](/documentation/AppKit/NSWindowDelegate/window(_:willResizeForVersionBrowserWithMaxPreferredSize:maxAllowedSize:))

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

[`windowWillEnterVersionBrowser(_:)`](/documentation/AppKit/NSWindowDelegate/windowWillEnterVersionBrowser(_:))

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

[`windowDidEnterVersionBrowser(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidEnterVersionBrowser(_:))

Tells the delegate that the window has entered version browsing.

[`windowWillExitVersionBrowser(_:)`](/documentation/AppKit/NSWindowDelegate/windowWillExitVersionBrowser(_:))

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

[`windowDidExitVersionBrowser(_:)`](/documentation/AppKit/NSWindowDelegate/windowDidExitVersionBrowser(_:))

Tells the delegate that the window has left version browsing.

### Instance Methods

[`previewRepresentableActivityItems(for:)`](/documentation/AppKit/NSWindowDelegate/previewRepresentableActivityItems(for:))

A collection of Preview-representable activity items, used for sharing and collaboration.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)