修复手机端文本框响应逻辑错误
This commit is contained in:
@@ -160,6 +160,7 @@ function love.touchpressed(id,x,y)
|
|||||||
if SCN.swapping then return end
|
if SCN.swapping then return end
|
||||||
if not touching then
|
if not touching then
|
||||||
touching=id
|
touching=id
|
||||||
|
WIDGET.unFocus(true)
|
||||||
love.touchmoved(id,x,y,0,0)
|
love.touchmoved(id,x,y,0,0)
|
||||||
end
|
end
|
||||||
x,y=xOy:inverseTransformPoint(x,y)
|
x,y=xOy:inverseTransformPoint(x,y)
|
||||||
@@ -172,14 +173,10 @@ function love.touchmoved(_,x,y,dx,dy)
|
|||||||
x,y=xOy:inverseTransformPoint(x,y)
|
x,y=xOy:inverseTransformPoint(x,y)
|
||||||
if SCN.touchMove then SCN.touchMove(x,y,dx/SCR.k,dy/SCR.k)end
|
if SCN.touchMove then SCN.touchMove(x,y,dx/SCR.k,dy/SCR.k)end
|
||||||
if WIDGET.sel then
|
if WIDGET.sel then
|
||||||
if touching then
|
if touching then WIDGET.drag(x,y,dx,dy)end
|
||||||
WIDGET.drag(x,y,dx,dy)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
WIDGET.cursorMove(x,y)
|
WIDGET.cursorMove(x,y)
|
||||||
if not WIDGET.sel then
|
if not WIDGET.sel then touching=false end
|
||||||
touching=false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function love.touchreleased(id,x,y)
|
function love.touchreleased(id,x,y)
|
||||||
@@ -188,8 +185,9 @@ function love.touchreleased(id,x,y)
|
|||||||
if id==touching then
|
if id==touching then
|
||||||
WIDGET.press(x,y,1)
|
WIDGET.press(x,y,1)
|
||||||
WIDGET.release(x,y)
|
WIDGET.release(x,y)
|
||||||
touching=false
|
WIDGET.cursorMove(x,y)
|
||||||
WIDGET.unFocus()
|
WIDGET.unFocus()
|
||||||
|
touching=false
|
||||||
end
|
end
|
||||||
if SCN.touchUp then SCN.touchUp(x,y)end
|
if SCN.touchUp then SCN.touchUp(x,y)end
|
||||||
if(x-lastX)^2+(y-lastY)^2<62 then
|
if(x-lastX)^2+(y-lastY)^2<62 then
|
||||||
|
|||||||
@@ -1083,9 +1083,12 @@ function WIDGET.focus(W)
|
|||||||
kb.setTextInput(true,0,y1,1,1)
|
kb.setTextInput(true,0,y1,1,1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function WIDGET.unFocus()
|
function WIDGET.unFocus(force)
|
||||||
if WIDGET.sel and WIDGET.sel.type=='inputBox'then kb.setTextInput(false)end
|
local W=WIDGET.sel
|
||||||
WIDGET.sel=false
|
if W and(force or not W.keepFocus)then
|
||||||
|
if W.type=='inputBox'then kb.setTextInput(false)end
|
||||||
|
WIDGET.sel=false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function WIDGET.cursorMove(x,y)
|
function WIDGET.cursorMove(x,y)
|
||||||
@@ -1110,8 +1113,8 @@ function WIDGET.drag(x,y,dx,dy)
|
|||||||
if not W then return end
|
if not W then return end
|
||||||
if W.type=='slider'or W.type=='textBox'then
|
if W.type=='slider'or W.type=='textBox'then
|
||||||
W:drag(x,y,dx,dy)
|
W:drag(x,y,dx,dy)
|
||||||
elseif not W:isAbove(x,y)and not WIDGET.sel.keepFocus then
|
elseif not W:isAbove(x,y)then
|
||||||
WIDGET.unFocus()
|
WIDGET.unFocus(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function WIDGET.release(x,y)
|
function WIDGET.release(x,y)
|
||||||
|
|||||||
@@ -26,6 +26,25 @@ local function _gotoSetting()
|
|||||||
SCN.go('setting_game')
|
SCN.go('setting_game')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local function _quit()
|
||||||
|
if TIME()-lastBackTime<1 then
|
||||||
|
NET.signal_quit()
|
||||||
|
else
|
||||||
|
lastBackTime=TIME()
|
||||||
|
LOG.print(text.sureQuit,'warn')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function _switchChat()
|
||||||
|
if inputBox.hide then
|
||||||
|
textBox.hide=false
|
||||||
|
inputBox.hide=false
|
||||||
|
WIDGET.focus(inputBox)
|
||||||
|
else
|
||||||
|
textBox.hide=true
|
||||||
|
inputBox.hide=true
|
||||||
|
WIDGET.unFocus(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
@@ -97,12 +116,7 @@ function scene.keyDown(key)
|
|||||||
if not inputBox.hide then
|
if not inputBox.hide then
|
||||||
scene.keyDown("switchChat")
|
scene.keyDown("switchChat")
|
||||||
else
|
else
|
||||||
if TIME()-lastBackTime<1 then
|
_quit()
|
||||||
NET.signal_quit()
|
|
||||||
else
|
|
||||||
lastBackTime=TIME()
|
|
||||||
LOG.print(text.sureQuit,'warn')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
elseif key=="return"then
|
elseif key=="return"then
|
||||||
local mes=STRING.trim(inputBox:getText())
|
local mes=STRING.trim(inputBox:getText())
|
||||||
@@ -111,20 +125,10 @@ function scene.keyDown(key)
|
|||||||
NET.sendMessage(mes)
|
NET.sendMessage(mes)
|
||||||
inputBox:clear()
|
inputBox:clear()
|
||||||
elseif #EDITING==0 then
|
elseif #EDITING==0 then
|
||||||
scene.keyDown("switchChat")
|
_switchChat()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
scene.keyDown("switchChat")
|
_switchChat()
|
||||||
end
|
|
||||||
elseif key=="switchChat"then
|
|
||||||
if inputBox.hide then
|
|
||||||
textBox.hide=false
|
|
||||||
inputBox.hide=false
|
|
||||||
WIDGET.focus(inputBox)
|
|
||||||
else
|
|
||||||
textBox.hide=true
|
|
||||||
inputBox.hide=true
|
|
||||||
WIDGET.unFocus()
|
|
||||||
end
|
end
|
||||||
elseif not inputBox.hide then
|
elseif not inputBox.hide then
|
||||||
print(1)
|
print(1)
|
||||||
@@ -371,8 +375,8 @@ scene.widgetList={
|
|||||||
not netPLY.getSelfReady() or
|
not netPLY.getSelfReady() or
|
||||||
NET.getlock('ready')
|
NET.getlock('ready')
|
||||||
end},
|
end},
|
||||||
WIDGET.newKey{name="hideChat",fText="...",x=380,y=35,w=60,font=35,code=pressKey"switchChat"},
|
WIDGET.newKey{name="hideChat",fText="...",x=380,y=35,w=60,font=35,code=_switchChat},
|
||||||
WIDGET.newKey{name="quit",fText="X",x=900,y=35,w=60,font=40,code=pressKey"escape"},
|
WIDGET.newKey{name="quit",fText="X",x=900,y=35,w=60,font=40,code=_quit},
|
||||||
}
|
}
|
||||||
|
|
||||||
return scene
|
return scene
|
||||||
Reference in New Issue
Block a user