0 votes

So I've been reading a bunch of posts on here that sound similar to my problem, but none of them seem to be fixing my issue.

In short, I have a VBoxContainer that is filled with buttons dynamically. I repeatedly add N buttons at once, and then remove them all when a button is selected. The buttons use Fill and Expand size flags to fill out the container when added, and they work fine when adding more buttons.

BUT, if I had let's say 5 buttons shown previously, and then I show 3 buttons afterwards, the container has now expanded vertically slightly and the bottom buttons are cut off.

On the buttons and containers I've tried toggling visible, setting rectsize and rectmin_size and resetting it, the only way I can programmatically get this thing to fix itself is by expanding the window by 20 pixels every time and then shrinking it again, but also only after delaying for a fraction of a second. Here's the fix I'm using:

func refresh_ui():
    OS.set_window_size(Vector2(OS.window_size.x, OS.window_size.y - 20))
    yield(get_tree().create_timer(0.01), "timeout")
    OS.set_window_size(Vector2(OS.window_size.x, OS.window_size.y + 20))

There has to be a more elegant way to fix this - what happens internally when I resize the window? Can I manually call that?

Godot version 3.2.3
in Engine by (12 points)

can you maybe share a project that shows the issue?
i'm not sure i understood it

Please log in or register to answer this question.

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.