Guest User

Untitled

a guest
Jul 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. extends LineEdit
  2.  
  3. var oldtext = "" #initial for text save
  4.  
  5. func _ready():
  6. pass
  7.  
  8. func _on_LineEdit_text_changed(text):
  9. var regex = RegEx.new()
  10. var regexmatch = RegExMatch.new()
  11. regex.compile("\\d+") #pattern for all digit number
  12.  
  13. if regex.search(text) == null or not text.is_valid_float(): #Check if the first character is null or not a float
  14. text = oldtext
  15. self.set_text(text) #set the text from previous line edit text
  16. elif regex.search(text) != null: #if else not a null
  17. regexmatch = regex.search(text) #place the result of search
  18. oldtext = text #save the text for next line edit
  19. pass
Add Comment
Please, Sign In to add comment