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

@@ -61,6 +61,7 @@ local InputText = InputContainer:new{
for_measurement_only = nil, -- When the widget is a one-off used to compute text height
do_select = false, -- to start text selection
selection_start_pos = nil, -- selection start position
is_keyboard_hidden = false, -- to be able to show the keyboard again when it was hidden (by VK itself)
}
-- only use PhysicalKeyboard if the device does not have touch screen
@@ -121,6 +122,11 @@ if Device:isTouchDevice() or Device:hasDPad() then
function InputText:onTapTextBox(arg, ges)
if self.parent.onSwitchFocus then
self.parent:onSwitchFocus(self)
else
if self.is_keyboard_hidden == true then
self:onShowKeyboard()
self.is_keyboard_hidden = false
end
end
if #self.charlist > 0 then -- Avoid cursor moving within a hint.
local textwidget_offset = self.margin + self.bordersize + self.padding
@@ -563,12 +569,21 @@ end
function InputText:onShowKeyboard(ignore_first_hold_release)
Device:startTextInput()
self.keyboard.ignore_first_hold_release = ignore_first_hold_release
UIManager:show(self.keyboard)
return true
end
function InputText:onHideKeyboard()
if not self.has_nav_bar then
UIManager:close(self.keyboard)
Device:stopTextInput()
self.is_keyboard_hidden = true
end
return self.is_keyboard_hiddenend
end
function InputText:onCloseKeyboard()
UIManager:close(self.keyboard)
Device:stopTextInput()