Control settings being reset

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

So, I’m currently working on getting a simple menu set up with Godot. The basic structure of the Scene is having a Control node as root, with a VBoxContainer stores all the items in the scene. There is a label at the top of the list of children of VBoxContainer called Label, and then another VBoxContainer for the buttons (called buttons).

  • I have set the size flags for buttons to be unchecked all.
  • I then set the left margin of the buttons VBoxContainer to 96 (5% of the display) and it moves all the buttons over as expected.
  • I save the scene.
  • I tab away from the scene and tab back and the left margin is set to 0 again.

This is not the only place I’ve had this issue and it’s not the only control that I’m having it with. Is there some sort of priority order of flags that I’m missing that would cause these values that I hard set to simply be ignored and reset to something else? I’m no expert with GUI design or with Godot, but my intuition tells me if I hard type a setting it should stick, not get overridden.

“I then set the left margin to 96 (5% of the display)…”

Where are you doing this ?

Remember that containers determine the size and position of your children. In any case you can use an interleaved margin container. And then set the margin in the margin container, in custom constant

estebanmolca | 2019-12-17 03:02

Sorry for the muddiness in the explanation! The margin for buttons (the second VBoxContainer) is where I’m setting left margin to 96. And I don’t know if I understand the second part. Are you saying there’s a node for margin that I can use as an item of the VBoxContainer to create the margin instead of actually setting it?

Edit: I did find the margin container. It is possible that this could work. But it would require a margin container for each button which, to me, sounds like a choppy workaround when I’m most likely missing something that should simply work. If need be I can grab screenshots or a demo that shows this problem.

sHerrmann | 2019-12-17 03:08

I was thinking about something like this:


The left margin of the buttons should be aligned?

estebanmolca | 2019-12-17 03:30

That actually does work. I’m not used to the whole “everything is a node” mentality so I just figured I could do this in as few nodes as possible…

Actually I’m still getting used to nodes as someone who worked in classes and structs >.<

sHerrmann | 2019-12-17 04:03

Yes, I also have a hard time understanding it and there are still many things that I don’t understand about Control nodes. But they cover most of the options and if something is missing you can make your own custom node. The important thing is to remember that when you use any control node of the container type, the position and margins of your children are controlled according to the properties of the container. These expand to cover the area of the container.

estebanmolca | 2019-12-17 04:26

:bust_in_silhouette: Reply From: Awxen

If you have container nodes whose margins you want to modify, you need to change properties under ‘custom constants’ instead or ‘margin’ or ‘anchor’.