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

@@ -8,14 +8,14 @@ local ReaderRotation = InputContainer:extend{
}
function ReaderRotation:init()
self:registerKeyEvents(true)
self:registerKeyEvents()
-- NOP our own gesture handling
self.ges_events = nil
end
function ReaderRotation:onGesture() end
function ReaderRotation:registerKeyEvents(init)
function ReaderRotation:registerKeyEvents()
if Device:hasKeyboard() then
self.key_events = {
-- these will all generate the same event, just with different arguments
@@ -30,13 +30,10 @@ function ReaderRotation:registerKeyEvents(init)
args = 90
},
}
elseif not init then
self.key_events = {}
end
end
ReaderRotation.onPhysicalKeyboardConnected = ReaderRotation.registerKeyEvents
ReaderRotation.onPhysicalKeyboardDisconnected = ReaderRotation.registerKeyEvents
--- @todo Reset rotation on new document, maybe on new page?