The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I'm having a problem with a container that has issues with vertical expansion. It doesn't activate the scroll bars of scroll containers it sits inside. It does not expand and push other elements lower when sitting among other instances inside of a vboxcontainer.

I suspect I'm missing something in regards to changing the size of the container but it doesn't always push parent control nodes to expand to accommodate it's size and thus activate scrolling or pushing other elements.

I have a custom container that orders it's children with this function:

func _on_sort_children():
    var max_width = rect_size.x
    var row_height = min_row_height
    var row_width = 0
    var row_index = 0
    for child in get_children():
        if row_width + child.rect_size.x < max_width:
            child.rect_position = Vector2(row_width, row_index * (row_height + margin.y))
            row_width += child.rect_size.x + margin.x
            row_index += 1
            child.rect_position = Vector2(0, row_index * (row_height + margin.y))
            row_width = child.rect_size.x + margin.x
    if rect_size.y < (row_index + 1) * row_height:
        rect_size.y = (row_index + 1) * row_height

It orders the dark boxes as it should and wraps them around when it hits the horizontal limit. It also adjusts the vertical height of the box to accommodate each row if needed.

Here is one container filled with boxes to excess where it should be causing a scroll wheel to appear since it is inside of a ScrollContainer:
enter image description here

Here are several of the same container that sits inside a VBoxContainer inside of a ScrollContainer. The scrollbar is there this time though for the whole thing. The first container is filled but doesn't expand and push it's siblings down like I would prefer.
enter image description here

Almost every element involved has their SizeFlags set to Fill and Expand at least vertically so I'm not sure what's happening. Perhaps I am not implementing something I should be with my custom Container?

Godot version v3.4.4.stable.official
in Engine by (30 points)

1 Answer

+1 vote

With the help of a friend I went through the documentation more thoroughly and spotted on the ScrollContainer page the line that says the rect_min_size needs to be changed in order to activate the scroll wheels showing up. Fixed both the issues updating those on the resized event.

by (30 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 Frequently asked questions and 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 [email protected] with your username.