Is there a way to have the line edit be active at the start of the scene, so I can directly type in words? I have found something about focus, but I am not sure if that is waht I need. And to get it processed using Enter, I just use the text_entered signal I guess.
LineEdit active at start
- Edited
The Control node has a couple functions for "stealing" the focus: grab_focus
and grab_click_focus
. I have no idea what the difference between the two are, but I tested with grab_focus
and it works.
Here is the code I used to test:
extends LineEdit
func _ready():
connect("text_entered", self, "on_text_entered");
grab_focus();
func on_text_entered(text):
print (text);
Hopefully this helps! :smile: (Side note: Welcome to the forums!)
Thank you TwistedTwigleg! I created a script for the LineEdit and it and pasted it in there. Then it worked
First I was trying it in the scipt attached to the Control node. That did not work. Even after changing self to $name_of_node, it did not give me the result. Must be me doing something wrong.
And for those who read this. This is written in the docs about it: Error connect( String signal, Object target, String method, Array binds=[ ], int flags=0 ) Connects a signal to a method on a target object. Pass optional binds to the call. Use flags to set deferred or one shot connections. See CONNECT_* constants. A signal can only be connected once to a method. It will throw an error if already connected. To avoid this, first use is_connected() to check for existing connections.