Handle arrow keys and enter in emulator text fields

This commit is contained in:
John Beard
2022-01-23 18:40:35 +01:00
committed by poire-z
parent e39ee325f9
commit ccc49036aa
2 changed files with 46 additions and 15 deletions

View File

@@ -543,30 +543,47 @@ end
-- is shown. Mostly likely to be in the emulator, but could be Android + BT
-- keyboard, or a "coder's keyboard" Android input method.
function InputText:onKeyPress(key)
if key["Backspace"] then
self:delChar()
elseif key["Del"] then
self:rightChar()
self:delChar()
elseif key["Left"] then
self:leftChar()
elseif key["Right"] then
self:rightChar()
elseif key["End"] then
self:goToEnd()
elseif key["Home"] then
self:goToHome()
local handled = true
if not key["Ctrl"] and not key["Shift"] and not key["Alt"] then
if key["Backspace"] then
self:delChar()
elseif key["Del"] then
self:rightChar()
self:delChar()
elseif key["Left"] then
self:leftChar()
elseif key["Right"] then
self:rightChar()
elseif key["Up"] then
self:upLine()
elseif key["Down"] then
self:downLine()
elseif key["End"] then
self:goToEnd()
elseif key["Home"] then
self:goToHome()
elseif key["Press"] then
self:addChars("\n")
elseif key["Tab"] then
self:addChars(" ")
else
handled = false
end
elseif key["Ctrl"] and not key["Shift"] and not key["Alt"] then
if key["U"] then
self:delToStartOfLine()
elseif key["H"] then
self:delChar()
else
handled = false
end
else
return false
handled = false
end
return true
return handled
end
-- Handle text coming directly as text from the Device layer (eg. soft keyboard