文本框控件输入功能加强
This commit is contained in:
@@ -255,9 +255,16 @@ function love.keyreleased(i)
|
|||||||
if SCN.swapping then return end
|
if SCN.swapping then return end
|
||||||
if keyUp[SCN.cur]then keyUp[SCN.cur](i)end
|
if keyUp[SCN.cur]then keyUp[SCN.cur](i)end
|
||||||
end
|
end
|
||||||
|
function love.textedited(text)
|
||||||
|
EDITING=text
|
||||||
|
end
|
||||||
function love.textinput(text)
|
function love.textinput(text)
|
||||||
if WIDGET.sel and WIDGET.sel.type=="textBox"then
|
local W=WIDGET.sel
|
||||||
WIDGET.sel.value=WIDGET.sel.value..text
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -636,6 +636,10 @@ function textBox:draw()
|
|||||||
if t then
|
if t then
|
||||||
gc.printf(t,x-412,y+h*.5-self.font*.7,400,"right")
|
gc.printf(t,x-412,y+h*.5-self.font*.7,400,"right")
|
||||||
end
|
end
|
||||||
|
setFont(self.font-10)
|
||||||
|
if WIDGET.sel==self then
|
||||||
|
gc.print(EDITING,x+10,y+5-self.font*1.4)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
function textBox:getInfo()
|
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)
|
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,
|
w= D.w,
|
||||||
h= D.h,
|
h= D.h,
|
||||||
secret= D.secret,
|
secret= D.secret,
|
||||||
|
regex= D.regex,
|
||||||
|
|
||||||
resCtr={
|
resCtr={
|
||||||
D.x+.5,D.y,
|
D.x+.5,D.y,
|
||||||
|
|||||||
Reference in New Issue
Block a user