RichTextLabel: Anyone have an idea on how to add a space between content and scrollbar?

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

The text content in a RichTextLabel by default seems to squish right up next to the scrollbar. Anyone have an idea how to give it more space?

e.g. Like have this red box just be empty space, so there is room between the text and scrollbar:

enter image description here

:bust_in_silhouette: Reply From: eod

OK here’s what I did:

Created a ScrollContainer then added a MarginContainer as a child, then added a RichTextLabel as a child to the MarginContainer.

For the RichTextLabel I set the scroll_active=false so that its scrollbar wouldn’t show. Then I adjusted the MarginContainer’s margin_right to my desired spacing.

Lastly, since I’m adding bbcode_text via gdscript, I needed to set the min height of the RichTextLabel like so to get the ScrollContainer’s scrollbar to work:

self.rect_min_size.y = self.get_content_height()

I was wondering if you were going to use a MarginContainer. Glad that you solved it.

Ertain | 2020-06-13 17:36

Yeah, I was just hoping that the RichTextLabel had its own margin or separation value for its scrollbar, so I wouldn’t have to hide it and create two additional nodes.

eod | 2020-06-13 20:05

RichTextLabel.get_content_height() has error

you nedd wait 1 frame with yield and after get_content_height()

yield ( get_tree (), "idle_frame" ) 

get_height_rich = $RichTextLabel.get_content_height()

zkmark | 2020-11-10 02:01

1 Like