Scrollcontainer with text

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

I have a scrollcontainer and a label but when adding text the scrollcontainer does not autoscroll to follow the text.
How do I get it to follow when there is too much text on my label?

Sorry, the answer I posted here earlier was intended for a different question (open in a different browser tab). I’ve hidden that answer and provided a new one…

jgodfrey | 2020-11-04 20:23

:bust_in_silhouette: Reply From: jgodfrey

I assume you’re trying to scroll things vertically as items are added to the bottom of the contained label? If that’s the case, you can get access to the vertical scrollbar and set it to its maximum value when ever you add text. Here’s some sample code snippets…

# Get a reference to the vertical scrollbar
onready var scrollbar = $ScrollContainer.get_v_scrollbar()

#  when you add text to the label, just scroll to the bottom...
$ScrollContainer/Label.text += "xxxx"
$ScrollContainer.scroll_vertical = scrollbar.max_value