<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindowDelegate/window(_:shouldDragDocumentWith:from:with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSWindowDelegate(im)window:shouldDragDocumentWithEvent:from:withPasteboard:"
  },
  "title" : "window(_:shouldDragDocumentWith:from:with:)"
}
-->

# window(_:shouldDragDocumentWith:from:with:)

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

```
@MainActor optional func window(_ window: NSWindow, shouldDragDocumentWith event: NSEvent, from dragImageLocation: NSPoint, with pasteboard: NSPasteboard) -> Bool
```

## Parameters

`window`

The window containing the document icon the user wants to drag.

`event`

The left-mouse down event that triggered the dragging operation.

`dragImageLocation`

The location of the origin of the document icon, in window coordinates, when the user started the dragging operation.

`pasteboard`

The pasteboard containing the contents of the document, which the delegate can modify.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> to allow the drag to proceed; <doc://com.apple.documentation/documentation/Swift/false> to prevent it. Before turning no the delegate can implement its own dragging behavior as described below.

## Discussion

Implementing this method enables an application to customize the process of dragging the window’s document icon. The delegate can prohibit the drag by returning <doc://com.apple.documentation/documentation/Swift/false>. Before returning <doc://com.apple.documentation/documentation/Swift/false>, the delegate can implement its own dragging behavior using  [`drag(_:at:offset:event:pasteboard:source:slideBack:)`](/documentation/AppKit/NSWindow/drag(_:at:offset:event:pasteboard:source:slideBack:)).

Alternatively, the delegate can enable a drag by returning <doc://com.apple.documentation/documentation/Swift/true>, for example, to override the default `NSWindow` behavior of prohibiting the drag of an edited document. In addition, the delegate can customize the pasteboard contents before returning <doc://com.apple.documentation/documentation/Swift/true>.

## See Also

[`representedURL`](/documentation/AppKit/NSWindow/representedURL)

The URL of the file the window represents.



---

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)