修正计算器键盘不能输入乘号和符号e不能正常工作的问题
This commit is contained in:
@@ -26,22 +26,7 @@ end
|
|||||||
|
|
||||||
scene.mouseDown=NULL
|
scene.mouseDown=NULL
|
||||||
function scene.keyDown(key)
|
function scene.keyDown(key)
|
||||||
if key:byte()>=48 and key:byte()<=57 then
|
if key:sub(1,2)=="kp"then
|
||||||
if sym=="="then
|
|
||||||
val=key
|
|
||||||
sym=false
|
|
||||||
elseif sym and not reg then
|
|
||||||
reg=val
|
|
||||||
val=key
|
|
||||||
else
|
|
||||||
if #val<14 then
|
|
||||||
if val=="0"then
|
|
||||||
val=""
|
|
||||||
end
|
|
||||||
val=val..key
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif key:sub(1,2)=="kp"then
|
|
||||||
scene.keyDown(key:sub(3))
|
scene.keyDown(key:sub(3))
|
||||||
elseif key=="."then
|
elseif key=="."then
|
||||||
if sym=="="then
|
if sym=="="then
|
||||||
@@ -85,10 +70,25 @@ function scene.keyDown(key)
|
|||||||
elseif key=="/"then
|
elseif key=="/"then
|
||||||
_autoReturn()
|
_autoReturn()
|
||||||
sym="/"
|
sym="/"
|
||||||
|
elseif key:byte()>=48 and key:byte()<=57 then
|
||||||
|
if sym=="="then
|
||||||
|
val=key
|
||||||
|
sym=false
|
||||||
|
elseif sym and not reg then
|
||||||
|
reg=val
|
||||||
|
val=key
|
||||||
|
else
|
||||||
|
if #val<14 then
|
||||||
|
if val=="0"then
|
||||||
|
val=""
|
||||||
|
end
|
||||||
|
val=val..key
|
||||||
|
end
|
||||||
|
end
|
||||||
elseif key=="return"then
|
elseif key=="return"then
|
||||||
val=val:gsub("e","")
|
val=val:gsub("e$","")
|
||||||
if sym and reg then
|
if sym and reg then
|
||||||
reg=reg:gsub("e","")
|
reg=reg:gsub("e$","")
|
||||||
val=
|
val=
|
||||||
sym=="+"and tostring((tonumber(reg)or 0)+tonumber(val))or
|
sym=="+"and tostring((tonumber(reg)or 0)+tonumber(val))or
|
||||||
sym=="-"and tostring((tonumber(reg)or 0)-tonumber(val))or
|
sym=="-"and tostring((tonumber(reg)or 0)-tonumber(val))or
|
||||||
|
|||||||
Reference in New Issue
Block a user