VirtualKeyboard: Allow hiding the keyboard with a hold on the down arrow key (#7751)

(And showing it again with a tap on an input field)
This commit is contained in:
hius07
2021-05-30 02:02:07 +03:00
committed by GitHub
parent c2c20199cd
commit 4973134fb6
3 changed files with 29 additions and 2 deletions

View File

@@ -111,7 +111,7 @@ function VirtualKey:init()
self.keyboard:delToStartOfLine()
end
--self.skiphold = true
elseif self.label =="" then
elseif self.label == "" then
self.callback = function() self.keyboard:leftChar() end
self.hold_callback = function()
self.ignore_key_release = true
@@ -127,6 +127,13 @@ function VirtualKey:init()
self.callback = function() self.keyboard:upLine() end
elseif self.label == "" then
self.callback = function() self.keyboard:downLine() end
self.hold_callback = function()
self.ignore_key_release = true
if not self.keyboard:onHideKeyboard() then
-- Keyboard was *not* actually hidden: refresh the key to clear the highlight
self:update_keyboard(false, true)
end
end
else
self.callback = function () self.keyboard:addChar(self.key) end
self.hold_callback = function()
@@ -762,6 +769,10 @@ function VirtualKeyboard:onClose()
return true
end
function VirtualKeyboard:onHideKeyboard()
return self.inputbox:onHideKeyboard()
end
function VirtualKeyboard:onPressKey()
self:getFocusItem():handleEvent(Event:new("TapSelect"))
return true