SwiftUI move via drag & drop

Is there any way for the drag source in a document based macOS application to get informed about a successful drop while using the draggable and dropTarget approach?

I would need this to remove the data from the document the data was dragged out from.

M Knaup

Answered by DTS Engineer in 797176022

@Knaup The dropDestination(for:action:isTargeted:) modifier returns a Boolean value which returns true if the drop operation was successful; otherwise, return false.

Its would be within this method you remove your data from the dragged source if the drop was successful.

@Knaup The dropDestination(for:action:isTargeted:) modifier returns a Boolean value which returns true if the drop operation was successful; otherwise, return false.

Its would be within this method you remove your data from the dragged source if the drop was successful.

Hi, first thanks for your answer. I know about this boolean value in the dropDestination. But in a document based application the dropDestination might refer to a different modelContext and thus I would need a way to refer to the modelContext of the dragSource somehow. As I need to remove the element from that context.

M Knaup

SwiftUI move via drag & drop
 
 
Q