优化输入框删除文字逻辑

This commit is contained in:
MrZ626
2021-02-06 23:53:39 +08:00
parent 33924b2c4a
commit 15e4f332ed

View File

@@ -761,10 +761,11 @@ function inputBox:keypress(k)
local t=self.value
if #t>0 and EDITING==""then
if k=="backspace"then
while t:byte(#t)>=128 and t:byte(#t)<192 do
t=sub(t,1,-2)
local p=#t
while t:byte(p)>=128 and t:byte(p)<192 do
p=p-1
end
t=sub(t,1,-2)
t=sub(t,1,p-1)
SFX.play("lock")
elseif k=="delete"then
t=""