Topic was automatically imported from the old Question2Answer platform.
Asked By
Ender
I need some help making a keypad that has buttons you press and then the text comes up in a textbox. I have the numbers working i just dont know how to make a backspace that will delete the last number func _on_key_1_pressed(): var Keytext = get_node("Keys_entered") Keytext.set_text(str(Keytext.get_text(),"1"))
Thanks
For the Backspace key, you really just need to remove the last character in the visible string (if it contains characters). Here’s a simple example using a button to add an “A” character, a button to “Delete” and a label to display the current text.
To use it, you’ll need a scene with the following nodes:
Control
ButtonA
ButtonDel
Label
Just wire the pressed() event of the two buttons to their handler functions in the below script.
extends Control
func _on_ButtonA_pressed():
$Label.text += "A"
func _on_ButtonDel_pressed():
var txt = $Label.text
if txt.length() > 0:
$Label.text = txt.substr(0, txt.length() - 1)
thank you, just testing it out then ill mark as the answer