1

How do I drag blocks of code, specifically SwiftUI views, around with my mouse in Xcode?

In this video https://developer.apple.com/videos/play/wwdc2020/10033/ about making widgets in swift, the author drags a block of code with his mouse. Between 4:50 and 4:57 he moves a VStack into a ZStack by nicely dragging it instead of cut and paste.

I have been searching, clicking, dragging, ctrl-shift-right-clicking, trying all sorts of things to do this. All my Google searches just come up with command+option+] or I hit how to implement drag and drop code, not how to drag and drop code, if you know what I mean.

I am using XCode 13.0

Tom Schulz
  • 612
  • 6
  • 23
  • 2
    It works fine for me! Maybe you are missing some thing! Select the block of code then start clicking on the parent of block then drag where you want then drop! – ios coder Nov 11 '21 at 22:30

1 Answers1

1

The secret here is you have to hold down the mouse before starting to move the block of code, and no command / alt / option trickery is needed. I was basically running down the hill when I just needed to walk down the hill.

I will resist the urge to delete this, it seems like a dumb question now, but there must be one other person at least out there this might help.

Tom Schulz
  • 612
  • 6
  • 23
  • When I triple click and drag through a case statement to select, then what? Hold down the mouse? It was held down during selection. If I let go then hold it down it deselects. Why can't this just work as expected? I want to be able to select something then drag a copy away. Usually option or something is held down to indicate copying. – Dirk Bester Dec 18 '22 at 03:10