Access to the scroll bar in a Scroll Container

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jay Kyburz
:warning: Old Version Published before Godot 3 was released.

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?

check out the image here

:bust_in_silhouette: Reply From: avencherus

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)

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.

Jay Kyburz | 2017-11-08 07:48

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.

avencherus | 2017-11-08 08:51

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.

Jay Kyburz | 2017-11-09 01:11

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.

earlroxas | 2018-08-29 02:45

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

Jay Kyburz | 2018-08-29 04:16