+1 vote

How do you go about customizing the scroll bar in the scroll container. More importantly, how do you change the WIDTH of the bar! I know themes might work, but I have only used them a bit, and dont know how to use them to change the scroll container's scroll bar size!

in Engine by (33 points)

4 Answers

+1 vote

I was wondering about this too. The only thing that sort of worked is:

get_v_scroll().set_scale(Vector2(1.5,1))
by (20 points)
0 votes

I have found a hint in the documentation:
https://docs.godotengine.org/en/stable/classes/class_scrollcontainer.html

You can access all the parameters of the scroll bar like this:

# get_v_scrollbar() for the vertical scrollbar

$ScrollContainer.get_v_scrollbar().rect_size.x = 12 

To conveniently figure out all the possible parameters and methods I suggest you add an extra VScrollBar node to your project as an example.

by (18 points)
edited by
0 votes

This worked for me:

$ScrollContainer.get_v_scrollbar().rect_min_size.x = 50

Had to be the rect min size. Didn't work with rect size. Couldn't find a way to do it with theming, unfortunately.

by (14 points)
0 votes

For Godot 3.2 onwards, you can achieve this via theme in the following way:
Edit: might work for earlier versions, not sure.

First assign a theme to your scroll container node.

Add a class item in that theme: "VScrollBar", V Scroll Bar appears in the property menu.

Click on "V Scroll Bar" and then click on "Styles", here you can use a stylebox type of your choice. (StyleBoxTexture glitches out for some reason when you try to assign to it).

If you choose to go with styleboxflat, click on it to change its properties, here you can set the color, border color shape etc. Here, you will also find an attribute titled: "Content Margin". Changing parameters under Content Margin allows you to change the breadth and height of your scrollbar. You might need to broaden "scroll" width in order for mouse hover to work in accordance to the width you have in mind.

by (28 points)
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.

Categories