+3 votes

Hey All,

I have a script that adds labels into a VBox that has a parent of ScrollContainer. Every time a label is entered I want to set the scroll bar to the bottom.& Not the top.

How would I work out where the bottom?


in Engine by (18 points)

2 Answers

+1 vote
Best answer

Check out this question.

by (10,523 points)
selected by
+1 vote

Jmbiv's youtube video explains this really well.

  • You can use the changed signal from the ScrollContainer's child ~ VScrollBar
  • Connect it to a function to scroll to the VScrolBar's max_value
  • But only when the max_value has changed
  func _ready() -> void:
     scrollbar.connect("changed", self, "scroll_to_bottom")
     max_scroll = scrollbar.max_value 

  func scroll_to_bottom(): 
    if max_scroll != scrollbar.max_value:
        max_scroll = scrollbar.max_value
        scroll_container.scroll_vertical = scrollbar.max_value

by (24 points)
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 Frequently asked questions and 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 [email protected] with your username.