Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created April 2, 2020 07:07
Show Gist options
  • Save wizard1066/f33bfaa7ce04930546896e656aeb6ae1 to your computer and use it in GitHub Desktop.
Save wizard1066/f33bfaa7ce04930546896e656aeb6ae1 to your computer and use it in GitHub Desktop.
abgwtp3
struct ContentView: View {
@State private var rect: CGPoint = CGPoint()
@State private var textText:String = ""
@State private var textValue:String = "Hello World"
var body: some View {
let dropDelegate = TheDropDelegate(textText: $textText)
return VStack {
Spacer()
Text(textValue).background(InsideView(rect: $rect))
.onDrag {
return NSItemProvider(object: self.textValue as NSItemProviderWriting) }
Spacer()
Text(textText)
.frame(width: 128, height: 20, alignment: .center)
.background(Color.yellow)
.onDrop(of: ["public.utf8-plain-text"], delegate: dropDelegate)
Spacer()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment