If you want the text when someone types and presses enter, add a signal on the LineEdit node to do this.
or are you trying to do something else?
HEy deaton64, yes when someone enters text in the LineEdit, then presses a button, I want to capture that text into a variable, is there an easy way? you said add a signal?
siten0308 | 2021-06-24 22:08
Usually, you enter text, press enter and that’s when the text is read.
Click on your LineEdit node in the Scene. Then in the Inspector click on the Node tab.
Double click on either text_changed or the text_entered signal and connect those to your code.
Then you end up with something like this to get the text:
func _on_LineEdit_text_entered(new_text: String) -> void:
Or, if you want to grab the contents of the text box when someone hits a button, you can:
deaton64 | 2021-06-25 07:50
cool thanks, for some reason, i am not sure why, i tried yours, and still didn’t work… then I found this when i right-click the child node: Copy Node Path
and added the .text like yours, and it worked… weird weird thing is… i did this before, were i copied the path like that, and tried it… and still didn’t work, not sure what is the difference between yesterday and today… but its working… big thank you
so it worked as such, I right click, copy node path, then added .text
siten0308 | 2021-06-25 18:15
Glad it works.
Be careful if you move the line edit object in the scene tree, the node path will change, but you code will point to the object in it’s original place.
You can get round this by searching for the node and assigning it to a variable and using that to reference the object. A bit like you were trying in the original post.
onready var sendSound :LineEdit = find_node("InputSound")
then you can access the text like this:
Makes your code neater as well.
deaton64 | 2021-06-25 23:15