-
-
Save blurymind/61a7cf4492a33796e04b13d41b130d76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends LineEdit | |
var updating = false | |
const allowed = ["0","1","2","3","4","5","6","7","8","9"] | |
func _ready(): | |
connect("text_changed",self,"otc") | |
func otc(text): | |
if updating: return | |
var pos = get_cursor_pos() | |
var n_text = "" | |
for i in range(text.length()): | |
if text[i] in allowed: | |
n_text += text[i] | |
else: | |
pos -=1 | |
updating = true | |
set_text(n_text) | |
set_cursor_pos(pos) | |
updating = false | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment