Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends LineEdit
- var oldtext = "" #initial for text save
- func _ready():
- pass
- func _on_LineEdit_text_changed(text):
- var regex = RegEx.new()
- var regexmatch = RegExMatch.new()
- regex.compile("\\d+") #pattern for all digit number
- if regex.search(text) == null or not text.is_valid_float(): #Check if the first character is null or not a float
- text = oldtext
- self.set_text(text) #set the text from previous line edit text
- elif regex.search(text) != null: #if else not a null
- regexmatch = regex.search(text) #place the result of search
- oldtext = text #save the text for next line edit
- pass
Add Comment
Please, Sign In to add comment