Instance Method

dragFile:fromRect:slideBack:event:

Initiates a dragging operation from the view, allowing the user to drag a file icon to any application that has window or view objects that accept files.

Declaration

- (BOOL)dragFile:(NSString *)filename fromRect:(NSRect)rect slideBack:(BOOL)flag event:(NSEvent *)event;

Parameters

fullPath

A string that specifies the absolute path for the file that is dragged.

aRect

A rectangle that describes the position of the icon in the view’s coordinate system.

slideBack

A Boolean that indicates whether the icon being dragged should slide back to its position in the view if the file isn’t accepted. The icon slides back to aRect if slideBack is YES, the file is not accepted by the dragging destination, and the user has not disabled icon animation; otherwise it simply disappears.

theEvent

The mouse-down event object from which to initiate the drag operation. In particular, its mouse location is used for the offset of the icon being dragged.

Return Value

YES if the view successfully initiates the dragging operation (which doesn’t necessarily mean the dragging operation concluded successfully). Otherwise, this method returns NO.

Discussion

This method must be invoked only within an implementation of the mouseDown: method.

See the NSDraggingSource, NSDraggingInfo, and NSDraggingDestination protocol specifications for more information on dragging operations.

See Also

Dragging Operations

- registerForDraggedTypes:

Registers the pasteboard types that the view will accept as the destination of an image-dragging session.

- unregisterDraggedTypes

Unregisters the view as a possible destination in a dragging session.

registeredDraggedTypes

The array of pasteboard drag types that the view can accept.

- beginDraggingSessionWithItems:event:source:

Initiates a dragging session with a group of dragging items.

- dragPromisedFilesOfTypes:fromRect:source:slideBack:event:

Initiates a dragging operation from the view, allowing the user to drag one or more promised files (or directories) into any application that has window or view objects that accept promised file data.

Deprecated
- shouldDelayWindowOrderingForEvent:

Allows the user to drag objects from the view without activating the app or moving the window of the view forward, possibly obscuring the destination.