Instance Method


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


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



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


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


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


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

Return Value

true to allow the drag to proceed; false to prevent it. Before turning no the delegate can implement its own dragging behavior as described below.


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 false. Before returning false, the delegate can implement its own dragging behavior using drag(_:at:offset:event:pasteboard:source:slideBack:).

Alternatively, the delegate can enable a drag by returning 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 true.

See Also