---
title: "dragImageForSelection(with:origin:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextview/dragimageforselection(with:origin:)"
---

# dragImageForSelection(with:origin:)

Returns an appropriate drag image for the drag initiated by the specified event.

## Declaration

```swift
func dragImageForSelection(with event: NSEvent, origin: NSPointPointer?) -> NSImage?
```

## Parameters

- `event`: The event that initiated the drag session.
- `origin`: On return, the lower-left point of the image in view coordinates.

## Return Value

Return Value An appropriate drag image for the drag initiated by event. May be nil, in which case a default icon will be used.

## Discussion

Discussion This method is used by dragSelection(with:offset:slideBack:). It can be called by others who need such an image, or can be overridden by subclasses to return a different image.

## See Also

### Dragging

- [dragOperation(for:type:)](appkit/nstextview/dragoperation(for:type:).md)
- [dragSelection(with:offset:slideBack:)](appkit/nstextview/dragselection(with:offset:slideback:).md)
- [acceptsGlyphInfo](appkit/nstextview/acceptsglyphinfo.md)
