控件系统文本框的显示调整,输入框新增clear方法
This commit is contained in:
@@ -260,19 +260,11 @@ function love.keyreleased(i)
|
|||||||
if SCN.keyUp then SCN.keyUp(i)end
|
if SCN.keyUp then SCN.keyUp(i)end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.textedited(text)
|
function love.textedited(texts)
|
||||||
EDITING=text
|
EDITING=texts
|
||||||
end
|
end
|
||||||
function love.textinput(text)
|
function love.textinput(texts)
|
||||||
local W=WIDGET.sel
|
WIDGET.textinput(texts)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.joystickadded(JS)
|
function love.joystickadded(JS)
|
||||||
|
|||||||
@@ -698,6 +698,9 @@ function inputBox:reset()
|
|||||||
kb.setTextInput(true)
|
kb.setTextInput(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function inputBox:clear()
|
||||||
|
self.value=""
|
||||||
|
end
|
||||||
function inputBox:isAbove(x,y)
|
function inputBox:isAbove(x,y)
|
||||||
return
|
return
|
||||||
x>self.x and
|
x>self.x and
|
||||||
@@ -878,11 +881,13 @@ function textBox:draw()
|
|||||||
local cap=self.capacity
|
local cap=self.capacity
|
||||||
|
|
||||||
|
|
||||||
--Frame
|
--Background
|
||||||
gc.setLineWidth(4)
|
|
||||||
gc.setColor(0,0,0,.3)
|
gc.setColor(0,0,0,.3)
|
||||||
gc.rectangle("fill",x,y,w,h)
|
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)
|
gc.rectangle("line",x,y,w,h)
|
||||||
|
|
||||||
--Slider
|
--Slider
|
||||||
@@ -890,7 +895,6 @@ function textBox:draw()
|
|||||||
gc.setLineWidth(2)
|
gc.setLineWidth(2)
|
||||||
gc.rectangle("line",x-25,y,20,h)
|
gc.rectangle("line",x-25,y,20,h)
|
||||||
local len=max(h*cap/#texts,26)
|
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)
|
gc.rectangle("fill",x-22,y+(h-len-6)*(scroll-cap)/(#texts-cap)+3,14,len)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1089,6 +1093,17 @@ function WIDGET.keyPressed(k)
|
|||||||
end
|
end
|
||||||
end
|
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={
|
local keyMirror={
|
||||||
dpup="up",
|
dpup="up",
|
||||||
dpdown="down",
|
dpdown="down",
|
||||||
|
|||||||
Reference in New Issue
Block a user