Using line edit

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bunnybot5555
:warning: Old Version Published before Godot 3 was released.

Hi, I am having trouble finding the correct void/function for line edit. I want to make it so when a certain word or phrase is typed it shows something else.

I don’t understand what you mean, do you want the word itself to turn into another one? Or do you want something to happen when a specific word is typed in a LineEdit?

Zylann | 2016-09-25 21:59

No just change the screen

bunnybot5555 | 2016-09-25 22:00

:bust_in_silhouette: Reply From: Zylann

You can listen to a signal from the LineEdit.
text_entered is triggered when the user presses Enter after typing text.
text_changed is triggered each time the user types a character.

You can execute some code when either of these happen by connecting the signal to a function. This is an example script that can be put on a LineEdit node:

extends LineEdit


# Note: you can also do this connection from the editor,
# by clicking the "Node" tab.
func _ready():
	connect("text_entered", self, "_on_text_entered")


func _on_text_entered(text):
	# Do whatever you want here
	if text == "Stuff":
		# Change scene...

Note:
In general, GUI nodes have signals you can listen to. Check for example the built-in doc from LineEdit, it’s really handy to know what to call, what events to listen :slight_smile:


The same can be found here: LineEdit — Godot Engine (latest) documentation in English

I would like to add an addendum to this answer. The online docs do not have a description of what each signal represents just a listing. I had to go to the docs in the engine to find those descriptions

anomalyaces | 2017-03-06 20:55