Scrolling Container not working

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tentamens

Hi there!
I’m trying to use the Scroll Container but it doesn’t seem to be detected that there are things inside of it (it’s not making the scroll bar on the side) I’m using button’s inside a Vbox maybe that’s why but I can’t seem to figure it out.

my scene tree :

Big thanks for the help!

It could be the child’s size ~ in this case the VBox container ~ double check the orange rectangle is wrapping all the children and that the size-flags and layout is set correctly

Ha-kuro | 2022-08-06 19:04

Hey there! thanks for the response,
But I’m confused about what you mean by the child’s size is off but here is my scene I’m trying to get to work - Imgur: The magic of the Internet

Tentamens | 2022-08-06 20:27

Ah thanks for the video, easier to see what’s happening.
Making UI in Godot can be tricky so it could be a number of things, but I’ll list a couple potential solutions:

  • The ScrollContainer needs to be smaller than its children, so make the ScrollContainer the size you want it and then let the children (e.g. VBoxContainer) be larger than the ScrollContainer
  • Using Layout can help when dealing with UI, you can make the container Full Rect layout to make its max height and width the same as the viewport

Lmk how you go :slight_smile:

Ha-kuro | 2022-08-07 17:16

Came across a similar issue that I was able to solve. In my case, even though I was adding a ton of content to my HBox (that was inside a scroll container and without clipping enabled), the size reported in Remote (debugger) was the same size as the gridcontainer which is unexpected. The HBox should have been way bigger. I ended up having to measure the width of all children in my HBox and then set the HBox min_size to the combined total. For me, I did this on resize but it could be done on add or wherever.

To see if this is your issue, look at remote and compare your gridcontainer dimensions with it’s top control node dimensions. If they are the same, this is likely the problem.

GrayDwarf | 2022-10-25 14:33

:bust_in_silhouette: Reply From: Kobrar

In order to calculate layout for its elements, containers need some information about those elements. Control type has got the API used for relaying this information. All contents of your Containers that you want displayed should extend Control. Purely non visual nodes like AudioPlayers etc are fine, but all visual elements should be Controls. You will have to figure out how to put together what you want from Controls or write a custom Control node.

so does that mean I cant use touchscreenbuttons with a scroll container scene tree - Imgur: The magic of the Internet or do I have to make them all children on control nodes which I just tried without success but ill continue to see if it is the fix.

any whom big thanks for the help!

Tentamens | 2022-08-07 21:20