beginDraggingSession(with:event:source:)
Initiates a dragging session with a group of dragging items.
Declaration
func beginDraggingSession(with items: [NSDraggingItem], event: NSEvent, source: any NSDraggingSource) -> NSDraggingSessionParameters
- items:
The dragging items. The frame property of each
NSDraggingItemmust be in the view’s coordinate system. - event:
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.
- source:
An object that serves as the controller of the dragging operation. It must conform to the Nsdraggingsource protocol and is typically the view itself or its Nswindow object.
Return Value
The dragging session for the drag.
Discussion
A basic drag starts by calling beginDraggingSessionWithItems:event:source:.
The caller can take the returned NSDraggingSession and continue to modify its properties. When the drag actually starts, the source is sent a draggingSession(_:willBeginAt:) message followed by multiple draggingSession(_:movedTo:) messages as the user drags.
Once the drag is ended or cancelled, the source receives a draggingSession(_:endedAt:operation:) method and the drag is complete.