Instance Method


Begins a dragging session.


func drag(_ image: NSImage, at baseLocation: NSPoint, offset initialOffset: NSSize, event: NSEvent, pasteboard pboard: NSPasteboard, source sourceObj: Any, slideBack slideFlag: Bool)



The object to be dragged.


Location of the image’s bottom-left corner in the window’s coordinate system. It determines the placement of the dragged image under the pointer.


The pointer’s location relative to the mouse-down location. Not used in macOS 10.4 and later.


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


The pasteboard that holds the data to be transferred to the destination.


The object serving as the controller of the dragging operation. It must conform to the NSDraggingSource protocol.


Specifies whether the drag image should slide back to baseLocation if it's rejected by the drag destination. Pass true to specify slide back behavior or false to specify that it should not.


This method should be invoked only from within a view’s implementation of the mouseDown(with:) or mouseDragged(with:) methods (which overrides the version defined in NSResponder class). Essentially the same as the NSView method of the same name, except that baseLocation is given in the NSWindow object’s base coordinate system.

See Also

Dragging Items

func registerForDraggedTypes([NSPasteboard.PasteboardType])

Registers a give set of pasteboard types as the pasteboard types the window will accept as the destination of an image-dragging session.

func unregisterDraggedTypes()

Unregisters the window as a possible destination for dragging operations.