From d15757dcc2c9bd16186e5e28faec600ef8d39c5f Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 27 Jun 2021 02:36:44 +0800 Subject: [PATCH] =?UTF-8?q?listBox=E6=8E=A7=E4=BB=B6=E6=96=B0=E5=A2=9Epop?= =?UTF-8?q?=E5=92=8Cremove=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/widget.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Zframework/widget.lua b/Zframework/widget.lua index 3f9b7d1b..5c6e49c5 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -14,7 +14,7 @@ local kb=love.keyboard local next=next local int,ceil,abs=math.floor,math.ceil,math.abs local max,min=math.max,math.min -local sub,ins=string.sub,table.insert +local sub,ins,rem=string.sub,table.insert,table.remove local getFont,setFont,mStr=getFont,setFont,mStr local mDraw,mDraw_X,mDraw_Y=ADRAW.draw,ADRAW.simpX,ADRAW.simpY local xOy=SCR.xOy @@ -929,7 +929,7 @@ function textBox:push(t) end function textBox:press(x,y) if not(x and y)then return end - self:drag(nil,nil,nil,0) + self:drag(0,0,0,0) if not self.fix and x>self.x+self.w-40 and y0 then self:clear() @@ -1085,10 +1085,22 @@ end function listBox:push(t) ins(self.list,t) end +function listBox:pop() + if #self.list>0 then + rem(self.list) + listBox:drag(0,0,0,0) + end +end +function listBox:remove() + if self.selected then + rem(self.list,self.selected) + self:drag(0,0,0,0) + end +end function listBox:press(x,y) x,y=x-self.x,y-self.y if not(x and y and x>0 and y>0 and x<=self.w and y<=self.h)then return end - self:drag(nil,nil,nil,0) + self:drag(0,0,0,0) y=int((y+self.scrollPos)/self.lineH)+1 if self.list[y]then if self.selected~=y then