Protocol

DropDelegate

An interface that you implement to interact with a drop operation in a view modified to accept drops.

Declaration

protocol DropDelegate

Overview

The DropDelegate protocol provides a comprehensive and flexible way to interact with a drop operation. Specify a drop delegate when you modify a view to accept drops with the onDrop(of:delegate:) method.

Alternatively, for simple drop cases that don’t require the full functionality of a drop delegate, you can modify a view to accept drops using the onDrop(of:isTargeted:perform:) or the onDrop(of:isTargeted:perform:) method. These methods handle the drop using a closure you provide as part of the modifier.

Topics

Instance Methods

func dropEntered(info: DropInfo)

Tells the delegate a validated drop has entered the modified view.

Required. Default implementation provided.

func dropExited(info: DropInfo)

Tells the delegate a validated drop operation has exited the modified view.

Required. Default implementation provided.

func dropUpdated(info: DropInfo) -> DropProposal?

Tells the delegate that a validated drop moved inside the modified view.

Required. Default implementation provided.

func performDrop(info: DropInfo) -> Bool

Tells the delegate it can request the item provider data from the given information.

Required.

func validateDrop(info: DropInfo) -> Bool

Tells the delegate that a drop containing items conforming to one of the expected types entered a view that accepts drops.

Required. Default implementation provided.

See Also

Supporting Drag and Drop in Views

func onDrag(() -> NSItemProvider) -> View

Activates the view as the source of a drag and drop operation.

func onDrop(of: [String], delegate: DropDelegate) -> View

Defines the destination of a drag and drop operation with the same size and position as the view using behavior controlled by the given delegate.

func onDrop(of: [String], isTargeted: Binding<Bool>?, perform: ([NSItemProvider], CGPoint) -> Bool) -> View

Defines the destination of a drag and drop operation with the same size and position as the view by handling dropped content and the drop location with the specified closure.

func onDrop(of: [String], isTargeted: Binding<Bool>?, perform: ([NSItemProvider]) -> Bool) -> View

Defines the destination for a drag and drop operation with the same size and position as the view by handling dropped content with the specified closure.

func itemProvider(Optional<() -> NSItemProvider?>) -> View

Provides a closure that vends the drag representation to be used for a particular data element.

struct DropInfo

The current state of a drop.

struct DropProposal

The behavior of a drop.

enum DropOperation

Operation types that determine how a drag and drop session resolves when the user drops a drag item.