How to make keypad? buttons with input value

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 009820

I created a numpad using buttons, and I want each button to have specific values, such as numbers or delete functions. How do I do that so each time I select a line edit and click a button it will input the specified value?

:bust_in_silhouette: Reply From: flurick

Well there is InputEventKey.new() but that seems undocumented at the moment so the best way is to just write into the field. An then for the delete button, make a new script that does not input but removes the last character or however you would like it to behave.

extends Button
export var character_to_input = "+"
func _pressed():
    focus_mode = Control.FOCUS_NONE
    var target = get_focus_owner()
    if target is TextEdit:
        target.insert_text_at_cursor(character_to_input)