How to swap location of widgets?

Hi Dotan,

To swap the location of widgets, you’ll need to use global as well as local variables. In case you’re not familiar, feel free to visit these pages to touch base:

Variables | Axure

Conditions, Values, and Variables | Core Training | Axure Software

And while there is a “target” variable you can use, this wouldn’t really adapt well for what you’re looking for since we’re dragging and dropping widgets (it’ll work nicely with a simple “Move” or “Set Text” action, on the other hand).

With that said, here goes!

  1. You’ll first need to add a “Set Variable Value” for each Dynamic Panels’ OnDragStart. This is so that when you later swap 1 with 2, and then 1 with 3, 3 takes 2 (now 1)'s place rather than 1’s original location.

  2. Add 6 global variables (for each of your 6 Dynamic Panels), and set their value to “This.x” or “LVAR1.x” where LVAR1 is the targeted panel widget. “This.x” will give you the current widget’s x location, while “LVAR1.x” will give you the targeted widget’s x location.

  3. Add 6 cases with “If area of This is over area of [widget]” to OnDragDrop where you “Move” the current and targeted widget to their respective locations. So it might look something like this:

Here’s a live example, and I’ve also attached the example file. Hope it helps!
SwapLocations.rp (103 KB)