0 votes

I have two LineEdit Controls (FireValue and FireStart) and want to get the value when FireValue changes into FireStart. I want to use Signals to do this. I want to keep my code organized so that FireValue does an emit_signal() and FireStart does the connect() and callback _set_fire().

Why doesn't the callback _set_fire() receive the signal when focus is exited in FireValue?

I know it works if I put all the code in Control1.gd but why does it not work when I have the split? Here is the code. Tested on both 3.1 and 3.2 Mac OS X.

#FireValue.gd
extends LineEdit
signal fire

func _ready():
    pass

func _on_FireValue_focus_exited(extra_arg_0: String) -> void:
    emit_signal("fire",self.text)
    pass # Replace with function body.

#FireStart.gd
extends LineEdit
signal fire

func _ready():
    connect("fire",self,"_set_fire")
    pass

func _set_fire(s):
    self.text=s
    pass

Project Screen shot
https://snipboard.io/QD2BAq.jpg

enter image description here

in Engine by (719 points)
edited by

1 Answer

0 votes
Best answer

Answering my own question. It seems you also need to specify the connect() method of the source node in this case FireValue.

E.g. Need to do this:

get_node("../FireValue").connect("fire",self,"_set_fire")

You need to know you are subscribing to that Nodes signals.

by (719 points)
selected by

Yeah, that's one of the necessities of signals. :-/

you can also make the connection via editor where the signal is defined, so the paths get corrected in case of a scene refactor (which is common for UI).

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.