Signal not being received by callback in 2nd node.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wyattb

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


:bust_in_silhouette: Reply From: wyattb

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.

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

Ertain | 2019-10-18 17:27

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).

eons | 2019-10-19 22:06