0 votes

So docs for ScrollBar and ScrollContainer are very scant. It appears that, like a few other controls, the scroll bar is set up to work exclusively with mouse input, but I'm making a game that uses joypads only. Changing ScrollContainer.scroll_vertical directly does not work, nor does calling ScrollContainer.set_v_scroll(x).

Essentially, I have recreated the ItemList node from scratch to work with joypad input, and what I need is to mirror the functionality of ItemList.ensure_current_is_visible(). To even start to do that, I need to be able to move the scroll bar from code. It would be a real chore to have to recreate the entire functionality of ScrollContainer as well =/ Can anyone help?

in Engine by (19 points)

2 Answers

0 votes
Best answer

Thanks to @Thebluefish on the Godot Discord for helping me figure this out. All that is needed is a manual call to $ScrollContainer.update() after changing the value of $ScrollContainer.scroll_vertical. As long as this doesn't happen in the _ready function, it works as intended.

by (19 points)
0 votes

I dont understand, do you want the joypad to act like a mouse (dragging the scroll), or do you want it to simply move the list up and down while pressing up and down?

If the latter, why do .scroll_vertical doesnt work? I dont have a joypad so i cannot check exactly, but it works with the keyboard: simply link the input(event) to the .scroll_vertical

func _input(event):
 if event.is_action_pressed("ui_up"):
by (1,213 points)

Sorry for the delay! @Thebluefish on the Godot Discord helped me solve this. It turns out that a manual call to $Scroll.update() was needed after updating scroll_vertical, and then everything worked fine.

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 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 webmaster@godotengine.org with your username.