Cannot lower dimensions of button

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

I have a scene with a generic button. The top node is a Control node, the child is a Button.
My issue is that I cannot lower the scale of the button below 175px by 200 px. Setting min size and size lower both get reset. I also cannot scale down in the viewport below these numbers. I do not want to use scaling, because it stretches my text in the button, AND I need to match the size of the Button exactly to the size of the Control parent (Because I instantiate lots of these buttons in code and add them to a HBoxContainer).

Is there a way to get the button to match any size I want? Also, is this the preferred way to work, with a Control node as the parent and the Button as a child?

:bust_in_silhouette: Reply From: TheFamousRat

Hello Tottel,

For Control nodes in Godot, it is generally not a very good idea to change sizes (and, for that matter, anchors and margin) manually. If you really need to do it, check the “Clip Text” checkbox in the Inspector, which will allow you to reduce the size of the button.

Here’s the catch : the HBoxContainer will ALWAYS stretch any of its nodes as much as possible. As such, the size of a button (and its margins and anchors) will get modified automatically every time you update it. As such, any parameters that you put for the size of the button will get overridden. As such, you have to use “Size flags” (it’s a tab in the “Control” part of the Inspector, when looking at the Button).

I tested it right now, and I think that for what you want, unchecking the “Fill” checkbox in the “Vertical” category seems to work. Don’t hesitate to play around with those other checkboxes, if you want your Node to be centered, at the top, at the bottom etc.

As for your question regarding Control as the root, I’m not experienced enough to give you a very valuable and detailed answer but yes, I think it’s a good idea. When building a scene, the root node should always be quite general, and then its childs fill more and more specific roles. For a typical GUI, the Control Node would just be here to fill all the screen, while its childs have more specific purposes (Popups with options, text dialogs etc.).

In the end of course, the best solution is different for every scene, and so you will have to judge what works best yourself. But, for a general scene with a few buttons in a HBoxContainer, yes, a Control node as root node is a good idea.

Hope this helps