0 votes

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?

in Engine by (16 points)
edited by

1 Answer

0 votes

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)
by (923 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.