mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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:
@@ -13,14 +13,14 @@ local ReaderPanning = InputContainer:extend{
|
||||
}
|
||||
|
||||
function ReaderPanning:init()
|
||||
self:registerKeyEvents(true)
|
||||
self:registerKeyEvents()
|
||||
-- NOP our own gesture handling
|
||||
self.ges_events = nil
|
||||
end
|
||||
|
||||
function ReaderPanning:onGesture() end
|
||||
|
||||
function ReaderPanning:registerKeyEvents(init)
|
||||
function ReaderPanning:registerKeyEvents()
|
||||
if Device:hasKeyboard() then
|
||||
self.key_events = {
|
||||
-- these will all generate the same event, just with different arguments
|
||||
@@ -45,13 +45,10 @@ function ReaderPanning:registerKeyEvents(init)
|
||||
args = {1, 0}
|
||||
},
|
||||
}
|
||||
elseif not init then
|
||||
self.key_events = {}
|
||||
end
|
||||
end
|
||||
|
||||
ReaderPanning.onPhysicalKeyboardConnected = ReaderPanning.registerKeyEvents
|
||||
ReaderPanning.onPhysicalKeyboardDisconnected = ReaderPanning.registerKeyEvents
|
||||
|
||||
function ReaderPanning:onPanning(args, _)
|
||||
local dx, dy = unpack(args)
|
||||
|
||||
Reference in New Issue
Block a user