Declaration
compose().dropConfiguration({
returns: SwiftUI.DropConfiguration,
perform?: (arg0: SwiftUI.DropSession) => void,
})nonisolated func dropConfiguration(
_ configuration: @escaping (DropSession) -> DropConfiguration
) -> some ViewParameters
configuration.returns*SwiftUI.DropConfigurationconfiguration.perform(arg0: SwiftUI.DropSession) => void
Return value
A view that configures a drop session in a way, described
Discussion
Below is an example of a view that accepts drop of Image type.
The view prefers drop operation move in a case when the source
supports it (the source will remove the images from its storage after
the drop operation).
If the source does not support moving images, the destination
will make copies.
ExampleView()
.dropDestination(for: Image.self) { images, _ in
process(images)
}
.dropConfiguration { dropSession in
if dropSession.suggestedOperations.contains(.move) {
return DropConfiguration(operation: .move)
}
return DropConfiguration(operation: .copy)
}frequently to allow specifying different operations for different drop locations in a view. Do not perform any expensive calculations in it.
of a drop session.
by the return value of the configuration parameter.
See also
More in Drag and drop.
- copyableSpecifies a list of items to copy in response to the system's Copy command.
- cuttableSpecifies an action that moves items to the Clipboard in response to the system's Cut command.
- documentLaunchSubtitleSets the subtitle displayed beneath the title on the document launch card, using a localized string resource.
- documentLaunchTitleSets the title displayed on the document launch card, using a localized string resource.
- draggableActivates this view as the source of a drag and drop operation.
- 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.
- fileExporterPresents a system dialog allowing the user to export a Transferable item to a file on disk.
- fileExporterFilenameLabelOn macOS, configures the fileExporter with a label for the file name field.
- fileImporterPresents a system dialog for allowing the user to import multiple files.
- fileMoverPresents a system dialog for allowing the user to move an existing file to a new location.
- itemProviderProvides a closure that vends the drag representation to be used for a particular data element.
- pasteDestinationSpecifies an action that adds validated items to a view in response to the system's Paste command.