+1 vote

Hey Guys, I'm new to Godot and trying to build some UI to see how it all works.

I have a scroll container, but the scroll bar is very small, looks like its about 8-10 pixels wide by default. I would like to make it 30px wide.

Is there a way to access the scrollbars of the scroll container in gdScript?
Would I be better off just hooking up my own scrollbar?
Do I need to make my own scroll container?

https://imgur.com/a/2U46X
check out the image here

in Engine by (79 points)

1 Answer

+2 votes
Best answer

They usually reside as children at indexes 0 and 1 in the container. There doesn't seem to be any API getters for them.

You can access them directly like this.

extends ScrollContainer

func _ready():

    var h_bar = get_child(0)
    var v_bar = get_child(1)
    h_bar.connect("value_changed", self, "h_change")
    v_bar.connect("value_changed", self, "v_change")

func h_change(val):
    print(val)

func v_change(val):
    print(val)
by (5,172 points)
selected by

Thanks very much for the help @avencherus!

Now that I have them, set_size does nothing. I wonder if they are being resized somewhere else after my script runs.

You're welcome.

The Controls in Godot I think are a bit rough around the edges still. There are some odd quirks you will run into, so I don't know the full story. Some things will not work as you expect, because there are some backend things going on. If you output the children of some nodes you'll find there can be all kinds of hidden Controls inside, and they don't behave as they do on their own.

Best of luck. X)

Worst comes to worst the tools exist to make your own Controls without too much extra effort.

Yes, thanks.

I think I'll try and read the source for the control and see if I can work out what is going on.

I thought it might be kind of fun to build my own anyhow.

Jay.

Excuse me, Jay.

Have you already know how to resize the scrollcontainer's scrollbar?
I want to resize it, but instead make it wider i want to make it 0px and the scrollbar floating in left side of the container (it's a v scrollbar) and drawn above the content.

Sorry, I don't think I ever did work it out. I don't remember too well.

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