封装inputBox控件的文本修改方法

This commit is contained in:
MrZ626
2021-05-13 19:48:07 +08:00
parent 38326bc3b6
commit 85e6810f99
5 changed files with 40 additions and 22 deletions

View File

@@ -37,7 +37,7 @@ local function clearResult()
waiting,lastSearch=0,false
end
local function search()
local input=inputBox.value:lower()
local input=inputBox:getText():lower()
clearResult()
local first
for i=1,#dict do
@@ -97,7 +97,7 @@ function scene.keyDown(key)
elseif key=="link"then
love.system.openURL(url)
elseif key=="delete"then
if #inputBox.value>0 then
if inputBox:hasText()then
clearResult()
inputBox:clear()
SFX.play('hold')
@@ -105,7 +105,7 @@ function scene.keyDown(key)
elseif key=="backspace"then
WIDGET.keyPressed("backspace")
elseif key=="escape"then
if #inputBox.value>0 then
if inputBox:hasText()then
scene.keyDown("delete")
else
SCN.back()
@@ -115,7 +115,7 @@ function scene.keyDown(key)
end
function scene.update(dt)
local input=inputBox.value
local input=inputBox:getText()
if input~=lastTickInput then
if #input==0 then
clearResult()