Size of Button with Text

When I put a text on a button, the size of button changes automatically to the size of the text and no longer can be changed…

Directly on canvas it works, but I want the buttons with text to be inside of a gridpanel so they all have a nice alignment in rows and columns, is that possible?

The size of the text makes the button expand as the button tries to accommodate it. Reduce the size of the text:

In addition, change the alignment to center/center so they sit pretty and in the centre.

edit: the above is in the GridPanel

1 Like

[…]but then the buttons
are not clickable at the position
where the text is, which is not really
an acceptable solution…

That’s because your text is set to Visible (default), change it to HitTestInvisible

I did not get the rest. Could you provide an example (can be a crude drawing) of what you’re trying to achieve?

While the grid panel is not perfect by any means, it is pretty flexible:

https://gyazo.com/491eeafbec541d8e83189c3c17128741

1 Like

Hello, reduce size of text also smalls the buttons, but I want buttons to be a bit bigger than text.

Found out that text placed not as child to the buttons does not change the buttons size, but then the buttons are not clickable at the position where the text is, which is not really an acceptable solution…

In the picture left and middle columns texts are unchilded, only right row text is placed as child, and with different font sizes it shrinks the buttons too. It should be independent from each other

I had each text placed as a child onto the buttons, after that the buttons shrinked to the length of text and it was not possible for me to make buttons bigger (or smaller).

The hit test invisible thing works, using that with text not as child seems fine. Thank you very much.

sizebox is what you need!