Can I relayout a control after changing its content?
Asked Answered
E

3

0

I'm trying to create dialog balloons and finding that the sizes don't update after I change the text in them. Is there a way to get a control to calculate it's size after making changes that will affect the sizes of its children?

Embus answered 29/7, 2023 at 2:17 Comment(0)
C
0

You'd better set the label size before update the text.

Comras answered 29/7, 2023 at 4:52 Comment(0)
E
0

Comras I don't know what size to set before the text is laid out. If the text is short, I want the dialog to shrink to fit it. Or if after splitting into multiple lines the text is less than the wrap width, I want the box to shrink to that size. So somehow I need to know the ultimate bounding box size of the text so I can set the size of the RichTextLabel.

Embus answered 29/7, 2023 at 9:40 Comment(0)
L
0

Embus It will require a bit of logic to get it working the way that I think you are aiming for. Couple things to consider as you approach writing this...

You can use the visible_characters and/or visible_ratio properties on the label to spell out the text over time. Use this as the base of the logic to update the size of the bubble. You will want to sort out the custom_minimum_size before hand and store a maximum_width and `maximum_height variable in the script.

Once you have those basic building blocks you can write the rest of the logic and throw in some tweens for smooth resizing.

Drop your script here once you have something. I would be happy to continue helping.

Limousine answered 29/7, 2023 at 13:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.