Instance Method

dragImage:at:offset:event:pasteboard:source:slideBack:

Begins a dragging session.

Declaration

- (void)dragImage:(NSImage *)image at:(NSPoint)baseLocation offset:(NSSize)initialOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pboard source:(id)sourceObj slideBack:(BOOL)slideFlag;

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 protocol.

slideFlag

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

Discussion

This method should be invoked only from within a view’s implementation of the mouseDown: or mouseDragged: 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

- registerForDraggedTypes:

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

- unregisterDraggedTypes

Unregisters the window as a possible destination for dragging operations.