0 votes

Hi everyone,

I have a button at the bottom of a ScrollContainer. I'd like that ScrollContainer's content-list to "jump back to the top position" when hitting that button. Any ideas how that could be done?

Godot version 3.3
in Engine by (461 points)

Thanks, for posting this question you saved my time searching for this problem.

1 Answer

0 votes
Best answer

Just did some quick experimentation and this seems to work.

func _on_Button_pressed():
    var sb = $ScrollContainer.get_v_scrollbar()
    sb.ratio = 0

So, wire your Button's press event to something like the above. That just gets the underlying scrollbar component and sets its ratio property to 0 (where 0 = the top and 1 = the bottom).

by (16,634 points)
selected by

Works like a charm, thank you very much!

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.