• Godot HelpGUI
  • How to make a fixed-width control node align to the right of its parent

Hi,

I've been trying to align a TextureButton (with a set width) to the right of its parent MarginContainer for a few frustrating hours now, and am completely out of ideas. Everything I have tried has resulted in the node appearing to sit where I want it to for a short time, only for it to randomly snap back to the left as soon as something else unrelated to it is added/changed. I have tried changing the grow direction, adjusting the margin values, moving it using the anchor controls, tweaking the position controls, apparently everything. Is this even possible?

Please, if anyone else has managed to figure out the esoteric series of steps required to work around this strange behavior I would be extremely grateful to hear how you managed to get it to work (genuinely).

I'm not entirely sure about what your trying do to, so I'd recommend posting a dummy project demonstrating your problem. However, from the sounds of it, I would try using a plain control/container node instead. Since most containers come with code that aligns their children in their own way.

Thanks for the reply. Using your answer and with a bit of googling / trial and error I managed to get it to work using a VBoxContainer containing a RichTextLabel as its last child which has the Fill size flag un-ticked (preserving the original size). My original assumption was that there was a way to anchor the top-right corner of a control node to a position within its parent container (a bit like absolute-positioning an element within a relative parent works in CSS), but unless I'm mistaken it seems that a combination of VBox's and HBoxes are necessary to position UI elements within containers (I'm probably mistaken).

Also, sorry about the saltiness earlier, I have a fever of 102 deg (f) and decided it was the perfect time to get some game dev done. Since then, I've decided that for the immediate future lying in bed and watching cartoons is a much more constructive use of my time :)

2 years later