mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
VirtualKeyBoard: Handle UX fallouts of VirtualKeyPopup overflow.
Don't close the popup on the first hold_release, ensuring it won't immediately close on a *different* key if the finger hasn't moved. If the finger *did* move, that's a quick swipe, and that's unaffected by this tweak.
This commit is contained in:
@@ -520,6 +520,17 @@ function VirtualKeyPopup:init()
|
||||
virtual_key.hold_callback = nil
|
||||
-- close popup on hold release
|
||||
virtual_key.onHoldReleaseKey = function()
|
||||
-- NOTE: Check our *parent* key!
|
||||
if parent_key.ignore_key_release then
|
||||
parent_key.ignore_key_release = nil
|
||||
return true
|
||||
end
|
||||
Device:performHapticFeedback("LONG_PRESS")
|
||||
if virtual_key.keyboard.ignore_first_hold_release then
|
||||
virtual_key.keyboard.ignore_first_hold_release = false
|
||||
return true
|
||||
end
|
||||
|
||||
virtual_key:onTapSelect(true)
|
||||
UIManager:close(self)
|
||||
return true
|
||||
@@ -630,13 +641,19 @@ function VirtualKeyPopup:init()
|
||||
}
|
||||
if position_container.dimen.x < 0 then
|
||||
position_container.dimen.x = 0
|
||||
-- We effectively move the popup, which means the key underneath our finger may no longer *exactly* be parent_key.
|
||||
-- Make sure we won't close the popup right away, as that would risk being a *different* key, in order to make that less confusing.
|
||||
parent_key.ignore_key_release = true
|
||||
elseif position_container.dimen.x + keyboard_frame.dimen.w > Screen:getWidth() then
|
||||
position_container.dimen.x = Screen:getWidth() - keyboard_frame.dimen.w
|
||||
parent_key.ignore_key_release = true
|
||||
end
|
||||
if position_container.dimen.y < 0 then
|
||||
position_container.dimen.y = 0
|
||||
parent_key.ignore_key_release = true
|
||||
elseif position_container.dimen.y + keyboard_frame.dimen.h > Screen:getHeight() then
|
||||
position_container.dimen.y = Screen:getHeight() - keyboard_frame.dimen.h
|
||||
parent_key.ignore_key_release = true
|
||||
end
|
||||
|
||||
self[1] = position_container
|
||||
|
||||
Reference in New Issue
Block a user