文本框控件输入功能加强
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user