ReaderUI: Refresh key_events handlers on keyboard hotplug

This commit is contained in:
NiLuJe
2022-11-01 00:17:25 +01:00
parent e0bfebb0b5
commit 09498d4bbb
15 changed files with 288 additions and 113 deletions

View File

@@ -35,9 +35,7 @@ local ReaderToc = InputContainer:extend{
}
function ReaderToc:init()
if Device:hasKeyboard() then
self.key_events.ShowToc = { { "T" } }
end
self:registerKeyEvents(true)
if G_reader_settings:hasNot("toc_items_per_page") then
-- The TOC items per page and items' font size can now be
@@ -62,6 +60,17 @@ end
function ReaderToc:onGesture() end
function ReaderToc:registerKeyEvents(init)
if Device:hasKeyboard() then
self.key_events.ShowToc = { { "T" } }
elseif not init then
self.key_events.ShowToc = nil
end
end
ReaderToc.onPhysicalKeyboardConnected = ReaderToc.registerKeyEvents
ReaderToc.onPhysicalKeyboardDisconnected = ReaderToc.registerKeyEvents
function ReaderToc:onReadSettings(config)
self.toc_ticks_ignored_levels = config:readSetting("toc_ticks_ignored_levels") or {}
self.toc_chapter_navigation_bind_to_ticks = config:readSetting("toc_chapter_navigation_bind_to_ticks")