Topic was automatically imported from the old Question2Answer platform.
Asked By
C:\Flavius
Hello, everyone.
I just finished my first program but I want it to be customizable. I mean I want a few variables to be choosable for the user.
For that I just need a few text boxes where the user must be able to write only numbers, and a way to read from those text boxes after pressing the Ok button.
I just need the name of the nodes, this is the first menu I make and I yet don’t know all the names.
Also, is there a way to read from the “Pick color” node too?
Thank you in advance!
Edit:
I tried this:
extends Label
func Read():
var NbOfEpcs = float(get_node(“LineNbOfEpicicles”).text);
var NbOfSegm = float (get_node(“LineNbOfSegments”).text);
var Rad = int(get_node(“LineRadiusOfCircumference”).text);
var Thicc = int(get_node(“LineThiccness”).text);
For the text, check out the LineEdit node. The ColorPicker is the node for the colors.
You can connect the “text_changed” and “text_entered” signals to wherever you want to check input text. For the ColorPicker node, you can use the “color_changed” signal or just pull out the color.
I created a scene hierarchy as follows for the below code:
-main (all signals connecting to methods in this node)
–LineEdit
—Button
—error(this is a TextEdit node)
–ColorPicker
extends Node2D
func _ready():
pass
func _process(delta):
pass
func _on_LineEdit_text_entered(new_text):
print("Entered Pressed!")
func _on_LineEdit_text_changed(new_text):
print("Text changed!")
print($LineEdit.text)
func _on_ColorPicker_color_changed(color):
print($ColorPicker.color)
func _on_Button_button_down():
var text = int($LineEdit.text)
if text != 0:
print("The number ", text, " was entered.")
$LineEdit.hide()
#Do somethihng with this number
else:
$LineEdit/error.show()
Here is a link to a good post about saving this data, if needed.
Thank you, it all worked, but the color picker… I need it to be able to set the value of two color variables (color of the circumference and color of the lines). I thought that there was a signal for when people pressed that plus (“+”) button. That way I could set two color variables.
Is there a way to do it?