InputContainer/FocusManager: Simplify key_events clearing on unplug

Thanks to @poire-z for the idea, it's indeed much nicer this way ;).
This commit is contained in:
NiLuJe
2022-11-01 23:22:07 +01:00
parent d585cd5d86
commit 925fd647dc
19 changed files with 66 additions and 141 deletions

View File

@@ -35,7 +35,7 @@ local ReaderToc = InputContainer:extend{
}
function ReaderToc:init()
self:registerKeyEvents(true)
self:registerKeyEvents()
if G_reader_settings:hasNot("toc_items_per_page") then
-- The TOC items per page and items' font size can now be
@@ -60,16 +60,13 @@ end
function ReaderToc:onGesture() end
function ReaderToc:registerKeyEvents(init)
function ReaderToc:registerKeyEvents()
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 {}