I've reported this issue on FB and this issue will be fixed in 18.1!
Post
Replies
Boosts
Views
Activity
Ok, here is the snippet.
import SwiftUI
struct ContentView: View {
@State var str: String = "Drag me"
var body: some View {
VStack(spacing: 100) {
Text(str)
.frame(width: 100, height: 100)
.background(.blue)
.onDrag {
NSItemProvider(object: String(str) as NSString)
}
VStack {
Text("Drop Here!")
}
.frame(width: 200, height: 200)
.background(.red)
.onDrop(of: [.text], delegate: MyDelegate())
}
}
}
struct MyDelegate: DropDelegate {
func performDrop(info: DropInfo) -> Bool {
return true
}
}
#Preview {
ContentView()
}