Godot 4.6
Question
I’m making a credits scene for my game. The text of the credits is in a RichTextLabel inside of a ScrollContainer parent.
I want to give the user the ability to scroll the text via keyboard input.
I successfully receive the keyboard input. When the input is received it calls scroll()
@onready var scroll_container:ScrollContainer = $MarginContainer/VBoxContainer/ScrollContainer
func scroll(amount:int):
scroll_container.set_v_scroll( scroll_container.get_v_scroll() + amount )
this does not scroll regardless of the value of the “amount” int.
I have also tried changing the value of the Scroll Container’s scroll bar, which also does not work.
var v_scroll:ScrollBar = scroll_container.get_v_scroll_bar()
var v:float = v_scroll.get_value()
var target:float = v - 10
v_scroll.set_value(target)
When I test the scene in debugger mode I could scroll with the mouse wheel. However, when I tried to change Scrollbar’s “Scroll Vertical” variable in the editor, it would immediately change back to zero.
Also interesting is that below code, would return 0 to the max var.
var max = scroll_container.get_v_scroll_bar().get_max()
I believe this has something to do with the problem.
Any help to fix or understand the issue would be appreciated, thanks!