0 votes

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

in Engine by (164 points)

1 Answer

0 votes

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()
by (164 points)

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

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.

RichTextLabel.getcontentheight() has error

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

yield ( get_tree (), "idle_frame" ) 

get_height_rich = $RichTextLabel.get_content_height()
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.