How to expand a RichTextLabel dynamically?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wombatTurkey
:warning: Old Version Published before Godot 3 was released.

Hey guys I’m trying to find a way to expand a RichTextLabel dynamically based on its content.

In fact, RichTextLabel already does this, well, partially.

For example:

I want to use the value of the scrollbar and resize it so the scrollbar isn’t shown. I love RichTextLabel’s text wrapping ability, but want to get rid of the scrollbar and expand it.

I did make a small little hack where I expanded the size in a while loop checking if the scrollbar was visible. This isn’t ideal as it locks the thread depending on how much you increment it by (pixels). Also, since a lot of new messages are going to be coming in from chat, wouldn’t be ideal.

I’m just basically trying to set the size of it based on how much you can scroll. Thanks in advance.

I also am looking at get_v_scroll().get_max() and then changing the height, but it returns a very high number, not sure why.

:bust_in_silhouette: Reply From: wombatTurkey

I’m dumb. It is get_max()… you just need to use a yield before it. (Why it wasn’t working previously):

yield(get_tree(), "idle_frame")
set_size(Vector2(get_size().width, get_v_scroll().get_max()))