From ad50475bb627679873279713c281f8766288c86a Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Tue, 26 Oct 2021 13:54:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AE=A1=E7=AE=97=E5=99=A8?= =?UTF-8?q?=E9=94=AE=E7=9B=98=E4=B8=8D=E8=83=BD=E8=BE=93=E5=85=A5=E4=B9=98?= =?UTF-8?q?=E5=8F=B7=E5=92=8C=E7=AC=A6=E5=8F=B7e=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E5=B7=A5=E4=BD=9C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/app_calc.lua | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/parts/scenes/app_calc.lua b/parts/scenes/app_calc.lua index 77e13144..7f3e140b 100644 --- a/parts/scenes/app_calc.lua +++ b/parts/scenes/app_calc.lua @@ -26,22 +26,7 @@ end scene.mouseDown=NULL function scene.keyDown(key) - if 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:sub(1,2)=="kp"then + if key:sub(1,2)=="kp"then scene.keyDown(key:sub(3)) elseif key=="."then if sym=="="then @@ -85,10 +70,25 @@ function scene.keyDown(key) elseif key=="/"then _autoReturn() 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 - val=val:gsub("e","") + val=val:gsub("e$","") if sym and reg then - reg=reg:gsub("e","") + reg=reg:gsub("e$","") val= sym=="+"and tostring((tonumber(reg)or 0)+tonumber(val))or sym=="-"and tostring((tonumber(reg)or 0)-tonumber(val))or