bet input now only permits numbers
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
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
|
||||
Reference in New Issue
Block a user