Topic was automatically imported from the old Question2Answer platform.
Asked By
bunnybot5555
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?
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
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