How do you rearrange the order of elements in a UMG Box?

I want the player to be able to rearrange weapons on his list mincraft/stardew style but I can’t find the BP node to move elements around in a horizontal/vertical/wrap box. Anyone familiar with this?

Very familiar, sadly. The functionality of inserting children into container lists is not exposed to BPs.

To pull it of in BPs

  • keep widgets in an array
  • swap array elements accordingly
  • clear the widget container
  • repopulate from the array

It’s not as inefficient as it sounds. The biggest drawback is slot formatting.

1 Like

So I can place say, a horizontal box with 2 text boxes in a created named variable array and it will hold all the settings of the Horizontal box and all those text boxes, or am I unaware of the kind of array you are talking about?

You want to change the order of elements on the ability / inventory bar - widgets that sit in a horizontal box. Add those widgets to an array and reorder that array instead. That is your new order of elements.

Similar to this:

But rather then inserting at the start / end you can actually swap elements:

316284-screenshot-2020-09-28-150623.jpg

2 Likes

You asked about moving elements in a horizontal box directly, the above applies. However…

Normally, you approach something like this quite differently, you do not keep your abilities / skills / items directly in a horizontal box. You create additional widgets that serve as slots. So you end up with a horizontal box with 10 empty slots that can hold any widget you need.

Each slot implements onDrop. If you drop onto a slot that already has something, you swap things around. If you drop onto a slot that is empty, you simply add the widget to that slot, and it will be automagically removed from the other one since widgets can have only 1 parent.

edit: just to visualise, here’s what I mean:

Image from Gyazo

It’s a widget with slots (more can be added dynamically, of course). The slots implement onDrop. While the abilities implement dragging.