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.
reviewable/pr7776/r1
NiLuJe 3 years ago committed by Frans de Jonge
parent 1054137641
commit 5a468b8cf2

@ -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

Loading…
Cancel
Save