RichTextLabel, ItemList - Scrolling from GDScript

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DimitriyPS
:warning: Old Version Published before Godot 3 was released.

I need to scroll (at the beginning) from GDScript components RichTextLabel, ItemList. How to do it?

:bust_in_silhouette: Reply From: GlaDOSik

A quick look at the documentation revealed that in case of RichTextLabel, you can call get_v_scroll(), which should give you VScrollBar object. You can then call VScrollBar.set_value(0.0). Another way would be to call RichTextLabel.scroll_to_line(0).

I don’t know if ItemList provides it’s own scroll bar (I didn’t use it so far) but because it looks it doesn’t, I would try to put ItemList in ScrollContainer and then call ScrollContainer.set_v_scroll(0). I didn’t test the code but it should give you a good idea how to scroll those nodes.

ItemList does have a scroll bar but it only appears when you have more items then can fit in the bounds of the node. So it makes sense that you’ve never seen it. That said, looking in the documentation I don’t see a get_v_scroll() function.

jelly | 2016-08-30 16:47

GlaDOSik Thank you. With RichTextLabel it works. At the ItemList added appeal to github.

DimitriyPS | 2016-08-31 12:19