Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UX] VirtualKeyPopup: respond to hold & pan release #4887

Merged
merged 3 commits into from Apr 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 26 additions & 1 deletion frontend/ui/widget/virtualkeyboard.lua
Expand Up @@ -131,6 +131,18 @@ function VirtualKey:init()
range = self.dimen,
},
},
HoldReleaseKey = {
GestureRange:new{
ges = "hold_release",
range = self.dimen,
},
},
PanReleaseKey = {
GestureRange:new{
ges = "pan_release",
range = self.dimen,
},
},
SwipeKey = {
GestureRange:new{
ges = "swipe",
Expand Down Expand Up @@ -219,6 +231,9 @@ function VirtualKey:onSwipeKey(arg, ges)
return true
end

VirtualKey.onHoldReleaseKey = VirtualKey.onTapSelect
VirtualKey.onPanReleaseKey = VirtualKey.onTapSelect

function VirtualKey:invert(invert, hold)
if invert then
self[1].inner_bordersize = self.focused_bordersize
Expand Down Expand Up @@ -298,11 +313,21 @@ function VirtualKeyPopup:init()
key_chars = key_chars,
width = parent_key.width,
height = parent_key.height,
hold_callback = nil,
}
virtual_key.hold_callback = nil

if v == key_char_orig then
virtual_key[1].background = Blitbuffer.COLOR_LIGHT_GRAY

-- restore ability to hold/pan release on central key after opening popup
virtual_key._keyOrigHoldPanHandler = function()
virtual_key.onHoldReleaseKey = virtual_key._onHoldReleaseKey
virtual_key.onPanReleaseKey = virtual_key._onPanReleaseKey
end
virtual_key._onHoldReleaseKey = virtual_key.onHoldReleaseKey
virtual_key.onHoldReleaseKey = virtual_key._keyOrigHoldPanHandler
virtual_key._onPanReleaseKey = virtual_key.onPanReleaseKey
virtual_key.onPanReleaseKey = virtual_key._keyOrigHoldPanHandler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does all that allow?
Not really understanding - looks to me you hold on the original keyboard key - and this virtual key (even with the same letter) is another VirtualKey object, so when you release that second one, the first one should still work. (?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't allow anything. ;-) It restricts the central key in the popup from responding as if there were an intentional hold release after opening. But after opening, it felt odd when it didn't respond like any other key.

end

table.insert(group, virtual_key)
Expand Down