Setting and locking positions of elements in editor

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

I’m trying to create a title page with labels, buttons and various containers, but when I change a property of an element, it snaps to the middle of parent(CenterContainer).
Even if i drag an element far outside of parent and then change the text, when I hit enter, the element snaps back to the same position.
I’m trying to duplicate title page from GitHub - AaronWizard/TheFallingBlocksExperience: Game about falling blocks
and it also has the same anchoring/snapping effect, but the positions are appropriately defined.
How can I define or remove those positions?

Before and after I hit enter in the text box(the template project I’m looking at).

After I hit enter in the text box(the duplicate I’m making)

:bust_in_silhouette: Reply From: Zylann

It does that because you placed this label inside a VBoxContainer. All containers in Godot are designed to automatically position their children according to various rules.

If you want to position your label manually, you have to either not put it as child of a container, or put a “dummy” control to hold its place, and add the label as child so that you can apply the extra offset (but thay might come with drawbacks in the case of labels).

I’m not sure what you mean by “positions are appropriately defined”.

By “positions are appropriately defined” I meant that labels are at the top and the buttons are placed below. In my remake everything snaps into one spot and I cannot find how to control that spot. I added a screenshot in the original question.

CustomUser | 2018-06-29 13:14

Ugh… that looks like a confusing behavior. It appears that the CenterContainer is modifying the anchors of VBoxContainer, that sounds weird… but it is kind of logical because anchors make no sense in such a container.

If I put items in the VBoxContainer they lay out vertically without a problem. The problem with your screen is, you have multiple VBoxContainers layed out on top of each other, so they can’t be laid out one after the other (for example you can see that the buttons are correctly placed because they are in the same VBoxContainer).

Finally, CenterContainer center all its children. Your scene has 3 children inside, so it centers them all, that’s normal. If you don’t want them stacked, use only one VBoxContainer as child and put all items in it.

Zylann | 2018-06-29 17:08

Thank you, after you pointed out that the element hierarchy is incorrect, the layout got resolved.

CustomUser | 2018-06-29 17:55