永久解决按输入框焦点和回车键的交互问题

This commit is contained in:
MrZ626
2021-06-08 21:34:07 +08:00
parent 80e95f3e27
commit 67f5ed49ec
4 changed files with 11 additions and 5 deletions

View File

@@ -272,7 +272,7 @@ function love.keypressed(key)
end end
elseif not SCN.swapping then elseif not SCN.swapping then
if SCN.keyDown then if SCN.keyDown then
SCN.keyDown(key) if #EDITING==0 then SCN.keyDown(key)end
elseif key=="escape"then elseif key=="escape"then
SCN.back() SCN.back()
else else

View File

@@ -1093,7 +1093,10 @@ function WIDGET.isFocus(W)
end end
function WIDGET.focus(W) function WIDGET.focus(W)
if WIDGET.sel==W then return end if WIDGET.sel==W then return end
if WIDGET.sel and WIDGET.sel.type=='inputBox'then kb.setTextInput(false)end if WIDGET.sel and WIDGET.sel.type=='inputBox'then
kb.setTextInput(false)
EDITING=""
end
WIDGET.sel=W WIDGET.sel=W
if W and W.type=='inputBox'then if W and W.type=='inputBox'then
local _,y1=xOy:transformPoint(0,W.y+W.h) local _,y1=xOy:transformPoint(0,W.y+W.h)
@@ -1103,7 +1106,10 @@ end
function WIDGET.unFocus(force) function WIDGET.unFocus(force)
local W=WIDGET.sel local W=WIDGET.sel
if W and(force or not W.keepFocus)then if W and(force or not W.keepFocus)then
if W.type=='inputBox'then kb.setTextInput(false)end if W.type=='inputBox'then
kb.setTextInput(false)
EDITING=""
end
WIDGET.sel=false WIDGET.sel=false
end end
end end

View File

@@ -133,7 +133,7 @@ function scene.keyDown(key)
if #mes>0 then if #mes>0 then
NET.sendMessage(mes) NET.sendMessage(mes)
inputBox:clear() inputBox:clear()
elseif #EDITING==0 then else
_switchChat() _switchChat()
end end
else else

View File

@@ -43,7 +43,7 @@ function scene.sceneBack()
end end
function scene.keyDown(k) function scene.keyDown(k)
if k=="return"and #EDITING==0 then if k=="return"then
createRoom() createRoom()
elseif k=="escape"then elseif k=="escape"then
SCN.go('net_rooms') SCN.go('net_rooms')