How do I get the position of a node in a container for swaping positions?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By IHate

I want to swap the positions of the children in a VboxContaine.
For example having an “add child button” that’s always in the last place even after adding a new child, I guess I could just destroy and add it back again. But what if I want to swap the fourth item starting from the top for the second?

Thanks in advance.

:bust_in_silhouette: Reply From: Dlean Jeans

You can call move_child():

move_child(get_child(3), 1) # move 4th to 2nd, 2nd pushed to 3rd
move_child(get_child(2), 3) # move 3rd to 4th

Thanks this works I was looking in the documentations inside the containers and couldn’t find it, guess I had to go higher on the tree.

IHate | 2019-06-30 13:14