This repository has been archived on 2026-05-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
magician/number_input.gd
T

18 lines
418 B
GDScript

class_name NumberEdit
extends LineEdit
## Only allows numeric input, discards everything else.
var _regex: RegEx = RegEx.new()
@export var submit_button: Button
func _ready() -> void:
_regex.compile("[^\\d]")
submit_button.disabled = true
func _on_text_changed(new_text: String) -> void:
if new_text.is_empty() or _regex.search(new_text):
submit_button.disabled = true
else:
submit_button.disabled = false