Scroll Container's scroll bar has size of zero despite being populated. Cannot make it scroll via code

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!

See this note here on the scroll_horizontal, the same applies to scroll_vertical:

Note: If you are setting this value in the Node._ready() function or earlier, it needs to be wrapped with Object.set_deferred(), since scroll bar’s Range.max_value is not initialized yet.

I am not setting the scroll value in _ready(), but when the user presses the arrow keys. I also tried “call deferred” just to see what would happen, but it made no difference as far as I could tell.