Read the text of an LineEdit

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

Hi
I wanna check, if the string of a LineEdit changed. At first I have the string “name 1”, and if a button is pressed, it has to check, if the string is not any more “name 1”. I tried it like this:
if $“Control/LineEdit1”.get_text() == “Name 1” :
How re you supposed to do it

:bust_in_silhouette: Reply From: johnygames

I do not see what is wrong with using your method other than the fact that you used double quotes after the $ sign where you shouldn’t.

You could also use the text_changed signal under the Node tab of your LineEdit . This returns the new string every time the text changes. Connect the text_changed to your main script and have your game check what the new_text is as you type on the LineEdit. Does this help?

I do not see what is wrong with using your method other than the fact that you used double quotes after the $ sign where you shouldn’t.

This is perfectly valid in GDScript. In fact, it’s even required if the path contains .. or /root.

Calinou | 2020-03-17 14:37