Created
July 17, 2016 01:39
-
-
Save MarianoGnu/11a14681654decf8543543a1e57ca955 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