The Godot Community Forums are back up and running! Please read the the announcement post for important information on what happened. Thanks!

Use Slider instead of Scrollbar for ScrollContainers?

GrampsGramps Posts: 28Member

I can never get the ScrollContainer's scrollbar to not look terrible and was wondering if there was a hack-y way to remove it and just use a slider, as I can theme them to look good. Any ideas?


  • MegalomaniakMegalomaniak Posts: 2,908Admin

    Sure, but you'd likely have to give up on using the scroll container and just build your own custom container out of a panel(not panel container, though perhaps that could work too?).

  • TwistedTwiglegTwistedTwigleg Posts: 3,129Admin

    Well, it would be a bit hacky (and I have no idea if it would work), but you can probably directly manipulate the scroll_horizontal and scroll_vertical properties of the ScrollContainer node through a Slider to get it to move the content inside correctly. The harder part may be getting the scrollbars in the ScrollContainer to become invisible, but maybe $ScrollContainer.get_h_scrollbar.visible = false would work? If it does, you could also set the min and max range of your Slider using similar code: $Horizontal_Slider_Node.max_value = get_h_scrollbar.max_value

  • GrampsGramps Posts: 28Member

    @Megalomaniak Yeah, I figured it might be something like that. Was hoping maybe I could kind of swap them out.

    @TwistedTwigleg Hmm, I will give it a shot as I am currently working on that scene. I'll report back if that does the trick! Cheers!

  • GrampsGramps Posts: 28Member

    OK, well, hiding the scrollbar on the ScrollContainer didn't work unless I disabled it. Even theme-ing it to be invisible didn't really work.

    For posterity...

    As per @Megalomaniak suggested, I swapped out my ScrollContainer for a Panel node then added a VSlider as a child above my VBoxContainer. My Panel was set to clip content outside of it, which cut the rest of my VBoxContainer off. I then moved the VBoxContainer until I could see the bottom of it in the Panel and noted the Y coordinate. I made this my minimum value on my VSlider.

    The VSlider then emitted a value_changed signal which would updated the position of the VBoxContainer and boom! A much nicer looking way of scrolling a panel.

    Thank you both so much for the advice and help!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file