DropSession
A description of a drop that is in progress.
Declaration
type DropSession = { readonly debugDescription: string; readonly id: DropSessionID; readonly itemsCount: number; readonly localSession: DropSessionLocalSession | null; readonly location: CGPoint; readonly phase: DropSessionPhase; readonly size: CGSize; readonly suggestedOperations: DropOperationSet; };struct DropSessionProperties
debugDescription*stringA textual representation of this instance, suitable for debugging.
The unique identifier of the drop session.
itemsCount*numberNumber of items for the drop.
localSession*DropSessionLocalSession | nullProvides additional information about a session if it originated within the app.
location*CGPointLocation of drop in the local coordinate space
phase*DropSessionPhaseThe phase of the current drop session.
size*CGSizeSize of the drop destination view.
suggestedOperations*DropOperationSetOperations suggested by the drag source.
Overview
Read DropSession.location to find where the drop landed,
DropSession.itemsCount for how many items it carries, and
DropSession.phase to follow the drag through its lifecycle.
The following example animates a drop at the point of the drop:
Color.pink
.frame(width: 400, height: 400)
.dropDestination(for: String.self) { titles, session in
process(titles: titles)
}To follow a drag while its phases change,
apply View.onDropSessionUpdated(_:).
Use DropSession.localSession to recognize a drag that started inside
your own app. It is nil for a drag that came from elsewhere.
From Apple’s SwiftUI documentation. Code samples there are Swift.
Used by
- dropConfigurationConfigures a drop session.
- dropDestinationDefines the destination of a drag and drop operation that provides a drop operation proposal and handles the dropped content with a closure that you specify.
- onDropSessionUpdatedSpecifies an action to perform on each update of an ongoing drop operation activated by dropDestination(:) or other drop modifiers.
See also
More in Drag and drop.
- DocumentConfigurationThe configuration of a document in a DocumentGroup.
- DocumentCreationSourceDescribes the source used to create a new document.
- DropConfigurationDescribes the behavior of the drop.
- DropOperationOperation types that determine how a drag and drop session resolves when the user drops a drag item.
- DropOperationSetA set of drop operations, corresponding to matching cases in DropOperation.
- DropSessionIDThe identifier of a drag session.
- DropSessionLocalSessionDescribes the session originated within the app.