Godot: LineEdit: changing text property via GDScript shouldn't trigger the text_changed signal

Created on 21 Aug 2018  路  5Comments  路  Source: godotengine/godot

I was trying to create a custom _LineEdit_.
So I created a plugin, I used _add_custom_type()_, etc.
The problem is that while it works in-game, it doesn't work inside the Godot editor.
You can use "stock" controls inside the editor with _EditorPlugin_ and create your editor custom GUI panel/window, but apparently you cannot use customized controls, they just don't work.
So I tried the tool option, and the control does respond, but changing the text for example, crashes Godot entirely.
So it looks to me that customized controls (extended from "stock" controls and added with _add_custom_type()_ do not work correctly inside the editor.

Included example project:
customized_control_bug.zip

Steps to reproduce:
Open the project. Notice that there's a custom panel on the bottom. Click on it to show it.
Notice there is a long line edit inside it. Click inside the line edit.
Try to type something.
Godot instantly crashes.
Examine the plugins scripts.
Open _"custom_line_edit.gd"_ and remove the _"tool"_ keyword.
Save, close and re-open the project.
See how it doesn't crashes but also doesn't change the text either, because the control is not responsive.

archived

Most helpful comment

Tbh I think this behavior is wrong because text_changed should be emitted for user interactions only

This was removed in #19050, so it's fixed on master already.

All 5 comments

Custom controls in the editor should work just as in a game, the editor is no different due to its use of the the same systems games can use (the editor is often compared to a "game made with Godot" for this reason). The crash you get is not normal behaviour, you might be hitting a specific bug here.

I think I found the specific bug.

You are connecting the text_changed signal and the connected function is changing the text again, automatically emitting the text_changedsignal again and again.

Tbh I think this behavior is wrong because text_changed should be emitted for user interactions only.

For now you can workaround this by changing the text member only if it's different from new text.

Using your example:

    if text != "Anything":
        text = "Anything"

Tbh I think this behavior is wrong because text_changed should be emitted for user interactions only

This was removed in #19050, so it's fixed on master already.

Thank you everyone for the support.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nunodonato picture nunodonato  路  3Comments

ducdetronquito picture ducdetronquito  路  3Comments

timoschwarzer picture timoschwarzer  路  3Comments

EdwardAngeles picture EdwardAngeles  路  3Comments

mefihl picture mefihl  路  3Comments