Godot: Can't create function named "_text_changed" in LineEdit

Created on 19 Apr 2019  路  8Comments  路  Source: godotengine/godot

Godot version: 3.1

Issue description:
Trying to create a function named _text_changed without any arguments in a script which extends LineEdit works fine. Trying to add an argument creates an error:
image
The problem is, that I can't find the "parent's function". void _text_changed() doesn't seem to exist.

Steps to reproduce:
Create LineEdit.
Attach a script.
Add the line void _text_changed(a):
Receive an error

bug confirmed core

All 8 comments

It is defined here:
https://github.com/godotengine/godot/blob/a61ad365f526e7acdbc556abc5678cd225e120d7/scene/gui/line_edit.h#L125

When you override a built in function, it needs to have the same arguments and return value.

While it may be defined in the code, it's not exposed to GDScript or listed in the documentations.
e.g. in https://docs.godotengine.org/en/3.1/classes/class_lineedit.html you can't find "_text_changed"

This may be a bigger issue then, since every function can be overridden, even if it's not exposed

It is exposed to GDScript:

scene/gui/line_edit.cpp
1514:   ClassDB::bind_method(D_METHOD("_text_changed"), &LineEdit::_text_changed);

Methods starting with an underscore are not included in the documentation, as they are not intended to be called directly (typically signal callbacks).

The exception is methods bound as virtual methods, such as Node._ready, and that's probably how LineEdit._text_changed should be bound too.

Okay, didn't know some functions aren't included in the documentation.
Changing it to a virtual function would be great, it would streamline the usage of such Control nodes
(e.g. Button._pressed instead of connecting to its own signal)

Closing since you can just connect to the signal using a different name

I'd argue it's a bug though, that this method is not visible in the docs.

I'd argue it is a bug since you can override methods not bound as virtual and get no errors in return. :smiley:

Still valid in 3.2.3, but fixed in 8ac9a97
I assume the underlying issue is still not fixed, but we no longer bind methods for signal use, so it might've become irrelevant.

Was this page helpful?
0 / 5 - 0 ratings