mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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:
@@ -391,6 +391,7 @@ function InputDialog:init()
|
||||
scroll_callback = self._buttons_scroll_callback, -- nil if no Nav or Scroll buttons
|
||||
scroll = true,
|
||||
scroll_by_pan = self.scroll_by_pan,
|
||||
has_nav_bar = self.add_nav_bar,
|
||||
cursor_at_end = self.cursor_at_end,
|
||||
readonly = self.readonly,
|
||||
parent = self,
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user