|
|
|
@ -95,6 +95,8 @@ function TouchMenuItem:init()
|
|
|
|
|
checked = true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.checkmark_tap_width = checked_widget:getSize().w + 2*Size.padding.default
|
|
|
|
|
|
|
|
|
|
-- text_max_width should be the TouchMenuItem width minus the below
|
|
|
|
|
-- FrameContainer default paddings minus the checked widget width
|
|
|
|
|
local text_max_width = self.dimen.w - 2*Size.padding.default - checked_widget:getSize().w
|
|
|
|
@ -168,11 +170,20 @@ function TouchMenuItem:onTapSelect(arg, ges)
|
|
|
|
|
end
|
|
|
|
|
if enabled == false then return end
|
|
|
|
|
|
|
|
|
|
local tap_on_checkmark = false
|
|
|
|
|
if ges and ges.pos and ges.pos.x then
|
|
|
|
|
local tap_x = BD.mirroredUILayout() and self.dimen.w - ges.pos.x - 1
|
|
|
|
|
or ges.pos.x
|
|
|
|
|
if tap_x <= self.checkmark_tap_width then
|
|
|
|
|
tap_on_checkmark = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- If the menu hasn't actually been drawn yet, don't do anything (as it's confusing, and the coordinates may be wrong).
|
|
|
|
|
if not self.item_frame.dimen then return end
|
|
|
|
|
|
|
|
|
|
if G_reader_settings:isFalse("flash_ui") then
|
|
|
|
|
self.menu:onMenuSelect(self.item)
|
|
|
|
|
self.menu:onMenuSelect(self.item, tap_on_checkmark)
|
|
|
|
|
else
|
|
|
|
|
-- c.f., ui/widget/iconbutton for the canonical documentation about the flash_ui code flow
|
|
|
|
|
|
|
|
|
@ -200,7 +211,7 @@ function TouchMenuItem:onTapSelect(arg, ges)
|
|
|
|
|
|
|
|
|
|
-- Callback
|
|
|
|
|
--
|
|
|
|
|
self.menu:onMenuSelect(self.item)
|
|
|
|
|
self.menu:onMenuSelect(self.item, tap_on_checkmark)
|
|
|
|
|
|
|
|
|
|
UIManager:forceRePaint()
|
|
|
|
|
end
|
|
|
|
@ -830,10 +841,15 @@ function TouchMenu:onSwipe(arg, ges_ev)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function TouchMenu:onMenuSelect(item)
|
|
|
|
|
function TouchMenu:onMenuSelect(item, tap_on_checkmark)
|
|
|
|
|
if self.touch_menu_callback then
|
|
|
|
|
self.touch_menu_callback()
|
|
|
|
|
end
|
|
|
|
|
if tap_on_checkmark and item.checkmark_callback then
|
|
|
|
|
item.checkmark_callback()
|
|
|
|
|
self:updateItems()
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
if item.tap_input or type(item.tap_input_func) == "function" then
|
|
|
|
|
if not item.keep_menu_open then
|
|
|
|
|
self:closeMenu()
|
|
|
|
|