LineEdit text_submitted Signal does not trigger

Godot Version

4.3

Question

Hey everyone,

I’m working on a high score entry system in Godot, where a LineEdit node should trigger the _on_text_submitted function when the user submits text. However, the signal doesn’t seem to be working.

Here’s the relevant code snippet:

 var entry = highscore_entry.instantiate()
 entry.show()
 
 # If the name field is empty, allow user input
 if item["name"] == "":
     entry.get_node("name").hide()
     entry.get_node("LineEdit").show()
 
     # Connect the signal
     entry.get_node("LineEdit").text_submitted.connect(_on_text_submitted)
     print(entry.get_node("LineEdit").is_connected("text_submitted", _on_text_submitted))  # Debugging
 
     user_score_item_pos = i
     $Confetti.emitting = true
     new_highscore = true            
 
     # Focus must be set in the next frame
     call_deferred("_grab_focus", entry.get_node("LineEdit"))
 else:
     entry.get_node("name").text = item["name"]
 
 entry.get_node("score").text = str("[right]" + str(item["score"]) + "[/right]")
 $Scores/Container.add_child(entry)

What’s the problem?

  1. The text_submitted signal is connected to _on_text_submitted, but it never triggers.
  2. The print() statement confirms that the signal is successfully connected.
  3. The LineEdit is visible and focused, so the user should be able to input text.

Has anyone encountered this issue before? Could it be related to how I’m instantiating and adding the node? Any help would be greatly appreciated!

Thanks in advance!

Hiere is the node-tree of the node tree when the game is running

How does your _on_text_submitted function look? Are you pressing enter while selecting the LineEdit?

You can paste code between three ticks ``` to create a code block

Thanks - I used the wrong markup and didn’t realize it until it was too late (i was not able to edit my post until it was approved).

I can post the callable-function later. But I know it was not called, since I added a breakpoint to the function.

I also added a LineEdit outside of the containers and added the signal - The signal is working until the scores-node is displayed - I use a tween to display it.

I found the issue. When submitting, a node was being made visible – but that node had another, still hidden, child node. So it looked like nothing happened.

So it actually had nothing to do with the signal.