<!--
{
  "availability" : [
    "macOS: 10.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindow/drag(_:at:offset:event:pasteboard:source:slideBack:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWindow(im)dragImage:at:offset:event:pasteboard:source:slideBack:"
  },
  "title" : "drag(_:at:offset:event:pasteboard:source:slideBack:)"
}
-->

# drag(_:at:offset:event:pasteboard:source:slideBack:)

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)
```

## Parameters

`image`

The object to be dragged.

`baseLocation`

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.

`initialOffset`

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

`event`

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

`pboard`

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

`sourceObj`

The object serving as the controller of the dragging operation. It must conform to the [`NSDraggingSource`](/documentation/AppKit/NSDraggingSource) protocol.

`slideFlag`

Specifies whether the drag image should slide back to `baseLocation` if it’s rejected by the drag destination. Pass <doc://com.apple.documentation/documentation/Swift/true> to specify slide back behavior or <doc://com.apple.documentation/documentation/Swift/false> to specify that it should not.

## Discussion

This method should be invoked only from within a view’s implementation of the [`mouseDown(with:)`](/documentation/AppKit/NSResponder/mouseDown(with:)) or [`mouseDragged(with:)`](/documentation/AppKit/NSResponder/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

[`-  dragImage:at:offset:event:pasteboard:source:slideBack:`](/documentation/AppKit/NSView/dragImage:at:offset:event:pasteboard:source:slideBack:)

Initiates a dragging operation from the view, allowing the user to drag arbitrary data with a specified icon into any application that has window or view objects that accept dragged data.



---

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)