From a330d29a28ff12f7f7bed64ed277ebab87bdb28e Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Feb 2021 23:25:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E7=B3=BB=E7=BB=9F=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=A1=86=E7=9A=84=E6=98=BE=E7=A4=BA=E8=B0=83=E6=95=B4?= =?UTF-8?q?=EF=BC=8C=E8=BE=93=E5=85=A5=E6=A1=86=E6=96=B0=E5=A2=9Eclear?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 16 ++++------------ Zframework/widget.lua | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index 1ef5faab..b414284e 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -260,19 +260,11 @@ function love.keyreleased(i) if SCN.keyUp then SCN.keyUp(i)end end -function love.textedited(text) - EDITING=text +function love.textedited(texts) + EDITING=texts end -function love.textinput(text) - local W=WIDGET.sel - if W and W.type=="inputBox"then - if not W.regex or text:match(W.regex)then - WIDGET.sel.value=WIDGET.sel.value..text - SFX.play("move") - else - SFX.play("finesseError",.3) - end - end +function love.textinput(texts) + WIDGET.textinput(texts) end function love.joystickadded(JS) diff --git a/Zframework/widget.lua b/Zframework/widget.lua index 177373ae..bd8e64cd 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -698,6 +698,9 @@ function inputBox:reset() kb.setTextInput(true) end end +function inputBox:clear() + self.value="" +end function inputBox:isAbove(x,y) return x>self.x and @@ -878,11 +881,13 @@ function textBox:draw() local cap=self.capacity - --Frame - gc.setLineWidth(4) + --Background gc.setColor(0,0,0,.3) gc.rectangle("fill",x,y,w,h) - gc.setColor(1,1,1) + + --Frame + gc.setLineWidth(4) + gc.setColor(COLOR[WIDGET.sel==self and"Y"or"W"]) gc.rectangle("line",x,y,w,h) --Slider @@ -890,7 +895,6 @@ function textBox:draw() gc.setLineWidth(2) gc.rectangle("line",x-25,y,20,h) local len=max(h*cap/#texts,26) - gc.setColor(COLOR[WIDGET.sel==self and"Y"or"W"]) gc.rectangle("fill",x-22,y+(h-len-6)*(scroll-cap)/(#texts-cap)+3,14,len) end @@ -1089,6 +1093,17 @@ function WIDGET.keyPressed(k) end end end +function WIDGET.textinput(texts) + local W=WIDGET.sel + if W and W.type=="inputBox"then + if not W.regex or texts:match(W.regex)then + WIDGET.sel.value=WIDGET.sel.value..texts + SFX.play("move") + else + SFX.play("finesseError",.3) + end + end +end local keyMirror={ dpup="up", dpdown="down",