From 6969b1f0da6a152945fea52df1fd991e27454870 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Tue, 20 Oct 2020 15:58:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=A1=86=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E5=8A=9F=E8=83=BD=E5=8A=A0=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 11 +++++++++-- Zframework/widget.lua | 5 +++++ main.lua | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index 743bb6dc..41cbe52d 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -255,9 +255,16 @@ function love.keyreleased(i) if SCN.swapping then return end if keyUp[SCN.cur]then keyUp[SCN.cur](i)end end +function love.textedited(text) + EDITING=text +end function love.textinput(text) - if WIDGET.sel and WIDGET.sel.type=="textBox"then - WIDGET.sel.value=WIDGET.sel.value..text + local W=WIDGET.sel + if W and W.type=="textBox"then + if not W.regex or text:match(W.regex)then + WIDGET.sel.value=WIDGET.sel.value..text + SFX.play("move") + end end end diff --git a/Zframework/widget.lua b/Zframework/widget.lua index 36936734..bd2d7416 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -636,6 +636,10 @@ function textBox:draw() if t then gc.printf(t,x-412,y+h*.5-self.font*.7,400,"right") end + setFont(self.font-10) + if WIDGET.sel==self then + gc.print(EDITING,x+10,y+5-self.font*1.4) + end end function textBox:getInfo() return format("x=%d,y=%d,w=%d,h=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h) @@ -650,6 +654,7 @@ function WIDGET.newTextBox(D) w= D.w, h= D.h, secret= D.secret, + regex= D.regex, resCtr={ D.x+.5,D.y, diff --git a/main.lua b/main.lua index 20466017..68265a58 100644 --- a/main.lua +++ b/main.lua @@ -17,6 +17,7 @@ MARKING=true LOADED=false NOGAME=false LOGIN=false +EDITING="" --Global Setting & Vars math.randomseed(os.time()*626)