<!--
{
  "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:usingRect:`](/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:toSize:`](/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

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

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

[`-  customWindowsToEnterFullScreenForWindow:onScreen:`](/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:startCustomAnimationToEnterFullScreenOnScreen: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.

[`-  customWindowsToExitFullScreenForWindow:`](/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:toObject:`](/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:shouldDragDocumentWithEvent:from:withPasteboard:`](/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

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

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

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

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)