I have a set of buttons with some text written on them. I want these buttons to have the same width as the screen, no matter the screen size. I also have text warp enabled, so that if the text is longer than the screen it takes two lines.
However if textwarp is needed, the button won't be big enough. This is what I see when there are two lines of text:
The weird thing is, if I resize the window to any other size and then back to the original size, the problem fixes itself.
I don't know why it works. The code currently is
func _ready() -> void:
hide()
get_tree().get_root().size_changed.connect(resize)
resize()
show()
func resize() -> void:
custom_minimum_size.x = get_viewport_rect().size.x
Where i'm hiding it and showing it again to fix a different error (where the first button would inexplicably be really large for no reason). If it's relevant, the buttons are childeren of a VBox, and they are instantiated entirely through code.
I have tried forcing it to redraw but queue_redraw() does nothing. I've tried setting a custom minimum y size, but I can't seem to find how to tell if textwarp has happened, and get_visible_line_count() seems to only be a thing with rich text.
Does anyone understand why this is happening or how to fix this?
This was apparently a known bug with Godot 4.3, fixed in Godot 4.4. Upgrading the code to Godot 4.4 fixed the issue.