mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
[TextViewer] Add hamburger menu to FocusManager and Menu key (#12365)
This commit is contained in:
parent
c2d58e525e
commit
49a991e82f
@ -15,6 +15,7 @@ local ButtonTable = require("ui/widget/buttontable")
|
|||||||
local CenterContainer = require("ui/widget/container/centercontainer")
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
||||||
local CheckButton = require("ui/widget/checkbutton")
|
local CheckButton = require("ui/widget/checkbutton")
|
||||||
local Device = require("device")
|
local Device = require("device")
|
||||||
|
local Event = require("ui/event")
|
||||||
local Geom = require("ui/geometry")
|
local Geom = require("ui/geometry")
|
||||||
local Font = require("ui/font")
|
local Font = require("ui/font")
|
||||||
local FrameContainer = require("ui/widget/container/framecontainer")
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
||||||
@ -111,6 +112,7 @@ function TextViewer:init(reinit)
|
|||||||
|
|
||||||
if Device:hasKeys() then
|
if Device:hasKeys() then
|
||||||
self.key_events.Close = { { Device.input.group.Back } }
|
self.key_events.Close = { { Device.input.group.Back } }
|
||||||
|
self.key_events.ShowMenu = { { "Menu" } }
|
||||||
end
|
end
|
||||||
|
|
||||||
if Device:isTouchDevice() then
|
if Device:isTouchDevice() then
|
||||||
@ -176,7 +178,7 @@ function TextViewer:init(reinit)
|
|||||||
title_multilines = self.title_multilines,
|
title_multilines = self.title_multilines,
|
||||||
title_shrink_font_to_fit = self.title_shrink_font_to_fit,
|
title_shrink_font_to_fit = self.title_shrink_font_to_fit,
|
||||||
left_icon = self.show_menu and "appbar.menu",
|
left_icon = self.show_menu and "appbar.menu",
|
||||||
left_icon_tap_callback = function() self:showMenu() end,
|
left_icon_tap_callback = function() self:onShowMenu() end,
|
||||||
close_callback = function() self:onClose() end,
|
close_callback = function() self:onClose() end,
|
||||||
show_parent = self,
|
show_parent = self,
|
||||||
}
|
}
|
||||||
@ -272,6 +274,16 @@ function TextViewer:init(reinit)
|
|||||||
show_parent = self,
|
show_parent = self,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- NT: add titlebar.left_button (hamburger menu) to FocusManager.
|
||||||
|
if Device:hasDPad() and not (Device:hasSymKey() or Device:hasScreenKB()) then
|
||||||
|
-- ButtonTable calls refocusWidget on init, but we'll mangle the layout,
|
||||||
|
-- so kill the initial highlight while FocusManager can still find the current focused item...
|
||||||
|
self.button_table:handleEvent(Event:new("Unfocus"))
|
||||||
|
table.insert(self.button_table.layout, 1, { self.titlebar.left_button })
|
||||||
|
-- And refocus manually on the *actual* layout
|
||||||
|
self.button_table:refocusWidget()
|
||||||
|
end
|
||||||
|
|
||||||
local textw_height = self.height - self.titlebar:getHeight() - self.button_table:getSize().h
|
local textw_height = self.height - self.titlebar:getHeight() - self.button_table:getSize().h
|
||||||
|
|
||||||
self.scroll_text_w = ScrollTextWidget:new{
|
self.scroll_text_w = ScrollTextWidget:new{
|
||||||
@ -589,7 +601,7 @@ function TextViewer:setTextBold(start_pos, len)
|
|||||||
self.text = text -- restore original text
|
self.text = text -- restore original text
|
||||||
end
|
end
|
||||||
|
|
||||||
function TextViewer:showMenu()
|
function TextViewer:onShowMenu()
|
||||||
local dialog
|
local dialog
|
||||||
local buttons = {
|
local buttons = {
|
||||||
{{
|
{{
|
||||||
|
Loading…
Reference in New Issue
Block a user