if toc item has expand/collapse state and tap select on the left side
the state switch action is triggered, otherwise goto the
linked page.
pull/1025/head
chrox 10 years ago
parent 1cb3c85f34
commit c994e30cff

@ -304,8 +304,15 @@ function ReaderToc:onShowToc()
toc_menu,
}
function toc_menu:onMenuChoice(item)
self.ui:handleEvent(Event:new("GotoPage", item.page))
function toc_menu:onMenuSelect(item, pos)
-- if toc item has expand/collapse state and tap select on the left side
-- the state switch action is triggered, otherwise goto the linked page
if item.state and pos.x < 0.5 then
item.state.callback()
else
toc_menu:close_callback()
self.ui:handleEvent(Event:new("GotoPage", item.page))
end
end
toc_menu.close_callback = function()

@ -270,24 +270,34 @@ function MenuItem:onShowItemDetail()
return true
end
function MenuItem:onTapSelect()
function MenuItem:getGesPosition(ges)
local dimen = self[1].dimen
return {
x = (ges.pos.x - dimen.x)/dimen.w,
y = (ges.pos.y - dimen.y)/dimen.h,
}
end
function MenuItem:onTapSelect(arg, ges)
local pos = self:getGesPosition(ges)
self[1].invert = true
UIManager:setDirty(self.show_parent, "partial")
UIManager:scheduleIn(0.1, function()
self[1].invert = false
UIManager:setDirty(self.show_parent, "partial")
self.menu:onMenuSelect(self.table)
self.menu:onMenuSelect(self.table, pos)
end)
return true
end
function MenuItem:onHoldSelect()
function MenuItem:onHoldSelect(arg, ges)
local pos = self:getGesPosition(ges)
self[1].invert = true
UIManager:setDirty(self.show_parent, "partial")
UIManager:scheduleIn(0.1, function()
self[1].invert = false
UIManager:setDirty(self.show_parent, "partial")
self.menu:onMenuHold(self.table)
self.menu:onMenuHold(self.table, pos)
end)
return true
end

Loading…
Cancel
Save