From 7b227181f28fbee6f5384be4410e2ece00cabd12 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 8 Jul 2021 02:00:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=AE=E7=9B=98=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E6=BB=91=E6=9D=A1=E6=88=96=E8=80=85=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=99=A8=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/widget.lua | 71 ++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/Zframework/widget.lua b/Zframework/widget.lua index 3113eee0..0f5a4727 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -558,7 +558,7 @@ function slider:scroll(n) end end function slider:arrowKey(k) - self:scroll(k=="left"or k=="up"and -1 or 1) + self:scroll((k=="left"or k=="up")and -1 or 1) end function WIDGET.newSlider(D)--name,x,y,w[,fText][,color][,unit][,smooth][,font=30][,change],disp,code,hide local _={ @@ -713,11 +713,12 @@ function selector:press(x) end function selector:scroll(n) local s=self.select - if n==-1 and s==1 or not n and s==#self.list then return end if n==-1 then + if s==1 then return end s=s-1 SYSFX.newShade(3,self.x,self.y-WIDGET.scrollPos,self.w*.5,60) else + if s==#self.list then return end s=s+1 SYSFX.newShade(3,self.x+self.w*.5,self.y-WIDGET.scrollPos,self.w*.5,60) end @@ -727,7 +728,7 @@ function selector:scroll(n) if self.sound then SFX.play('prerotate')end end function selector:arrowKey(k) - self:scroll(k=="left"or k=="up"and -1 or 1) + self:scroll((k=="left"or k=="up")and -1 or 1) end function WIDGET.newSelector(D)--name,x,y,w[,fText][,color][,sound=true],list,disp,code,hide @@ -1333,43 +1334,45 @@ function WIDGET.keyPressed(k,isRep) if not isRep then WIDGET.press() end - elseif kb.isDown("lshift","lalt","lctrl")then - --Control some widgets with arrowkeys when hold shift/ctrl/alt - if W and W.arrowKey then W:arrowKey(k)end elseif k=="up"or k=="down"or k=="left"or k=="right"then - if not W then - for _,w in next,WIDGET.active do - if not w.hide and w.isAbove then - WIDGET.focus(w) - return + if kb.isDown("lshift","lalt","lctrl")then + --Control some widgets with arrowkeys when hold shift/ctrl/alt + if W and W.arrowKey then W:arrowKey(k)end + else + if not W then + for _,w in next,WIDGET.active do + if not w.hide and w.isAbove then + WIDGET.focus(w) + return + end end - end - elseif W.getCenter then - local WX,WY=W:getCenter() - local dir=(k=="right"or k=="down")and 1 or -1 - local tar - local minDist=1e99 - local swap_xy=k=="up"or k=="down" - if swap_xy then WX,WY=WY,WX end -- note that we do not swap them back later - for _,W1 in ipairs(WIDGET.active)do - if W~=W1 and W1.resCtr and not W1.hide then - local L=W1.resCtr - for j=1,#L,2 do - local x,y=L[j],L[j+1] - if swap_xy then x,y=y,x end -- note that we do not swap them back later - local dist=(x-WX)*dir - if dist>10 then - dist=dist+abs(y-WY)*6.26 - if dist10 then + dist=dist+abs(y-WY)*6.26 + if dist