LineEdit size inside text_changed signal with "Expand to Text Length" enabled

Godot Version

v4.4.1.stable.official [49a5bc7b6]

Question

I have a LineEdit-Node with “Expand to Text Length” enabled. When I remove something from that LineEdit text and the text_changed signal gets called and I call the size attribute of the EditLine, it’s the same size as before the change. The size itself changes but it just doesn’t seem to update the size attribute soon enough when I want to use it.

In my code “_on_word_block_text_changed” is just a renamed “_on_text_changed” signal, “wordBlock” is the name of the LineEdit-Node and "word” is a variable I’m using elsewhere in the code.

Code:

Console:

Is it possible to get the new size when something from the text gets removed? Thanks in advance!

You could await a process frame before getting the size of the LineEdit.

Thanks for your answer! Should I do this as a coroutine? Or is there a simpler way?
Edit: Didnt know that “await” was literally a thing. That solves it now as a workaround but I still wonder why it even happens.

1 Like

I think it happens because the size change is done in a step after the lineedit function is called that frame.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.