How to move a ScrollBar in GDScript?

RammschnevRammschnev Posts: 2Member
edited September 2018 in GUI

(For Godot 3.0)

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?


Tags :


  • RammschnevRammschnev Posts: 2Member
    Answer ✓

    Thanks to @Thebluefish from the Discord server, all that's required is this:

    func _some_func():
        # This will not work in _ready, should work elsewhere
        var scroll_container = get_node("./ScrollContainer")
  • MegalomaniakMegalomaniak Posts: 1,086Admin

    Nice. Thanks for returning to post the answer for others to find, too. :)

Sign In or Register to comment.