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: close on hold release #4891

Merged
merged 3 commits into from
Apr 10, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions frontend/ui/widget/virtualkeyboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,16 @@ function VirtualKey:onUnfocus()
self[1].inner_bordersize = 0
end

function VirtualKey:onTapSelect()
function VirtualKey:onTapSelect(skip_flash)
if self.flash_keyboard and not self.skiptap then
self[1].inner_bordersize = self.focused_bordersize
self:update_keyboard(false, true)
if self.callback then
self.callback()
end
UIManager:tickAfterNext(function() self:invert(false) end)
if not skip_flash then
Frenzie marked this conversation as resolved.
Show resolved Hide resolved
UIManager:tickAfterNext(function() self:invert(false) end)
end
else
if self.callback then
self.callback()
Expand Down Expand Up @@ -259,7 +261,11 @@ function VirtualKeyPopup:onTapClose(arg, ges)
end

function VirtualKeyPopup:onClose()
local dimen = self.dimen
UIManager:close(self)
UIManager:setDirty(self, function()
return "partial", dimen
end)
return true
end

Expand Down Expand Up @@ -314,7 +320,14 @@ function VirtualKeyPopup:init()
width = parent_key.width,
height = parent_key.height,
}
-- don't open another popup on hold
virtual_key.hold_callback = nil
-- close popup on hold release
virtual_key.onHoldReleaseKey = function()
virtual_key:onTapSelect(true)
UIManager:close(self)
end
virtual_key.onPanReleaseKey = virtual_key.onHoldReleaseKey

if v == key_char_orig then
virtual_key[1].background = Blitbuffer.COLOR_LIGHT_GRAY
Expand All @@ -340,7 +353,7 @@ function VirtualKeyPopup:init()
end
end
table.insert(vertical_group, group)
table.insert(VirtualKeyPopup.layout, layout_horizontal)
table.insert(self.layout, layout_horizontal)
end
horizontalRow(extra_key_chars, horizontal_group_extra)
table.insert(vertical_group, v_key_padding)
Expand All @@ -359,14 +372,14 @@ function VirtualKeyPopup:init()
CenterContainer:new{
dimen = Geom:new{
w = parent_key.width*3 - 2*Size.border.default + 4*parent_key.keyboard.key_padding,
h = parent_key.height*4 - 2*Size.border.default + 5*parent_key.keyboard.key_padding,
h = parent_key.height*4 - 2*Size.border.default + 6*parent_key.keyboard.key_padding,
},
vertical_group,
}
}
keyboard_frame.dimen = keyboard_frame:getSize()

VirtualKeyPopup.ges_events = {
self.ges_events = {
TapClose = {
GestureRange:new{
ges = "tap",
Expand All @@ -375,10 +388,10 @@ function VirtualKeyPopup:init()
}

if Device:hasDPad() then
VirtualKeyPopup.key_events.PressKey = { {"Press"}, doc = "select key" }
self.key_events.PressKey = { {"Press"}, doc = "select key" }
end
if Device:hasKeys() then
VirtualKeyPopup.key_events.Close = { {"Back"}, doc = "close keyboard" }
self.key_events.Close = { {"Back"}, doc = "close keyboard" }
end

local position_container = WidgetContainer:new{
Expand All @@ -401,9 +414,9 @@ function VirtualKeyPopup:init()
position_container.dimen.y = Screen:getHeight() - keyboard_frame.dimen.h
end

VirtualKeyPopup[1] = position_container
self[1] = position_container

UIManager:show(VirtualKeyPopup)
UIManager:show(self)

UIManager:setDirty(self, function()
return "ui", keyboard_frame.dimen
Expand Down