Instance Method

onDrop(of:delegate:)

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

Declaration

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

Parameters

supportedTypes

The uniform type identifiers that describe the types of content this view can accept through drag and drop. If the drag and drop operation doesn’t contain any of the supported types, then this drop destination doesn’t activate and isTargeted doesn’t update.

delegate

A type that conforms to the DropDelegate protocol. You have comprehensive control over drop behavior when you use a delegate.

Return Value

A view that provides a drop destination for a drag operation of the specified types.

See Also

Supporting Drag and Drop in Views

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

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

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

Defines the destination for a drag and drop operation with the same size and position as this view, handling dropped content and the drop location with the given closure.

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software