mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
None[1] of them actually rely on their own onGesture handler, they all register their own stuff to ReaderUI's. Hotfix #9710 revealed that the way this was handled didn't exactly work as expected ;). The only thing that consumes ges_events is InputContainer's onGesture method. All these modules *extend* InputContainer, but none of them *implement* a custom onGesture, so self.onGesture = nil was just a NOP, they always access InputContainer's method via inheritance. If we actively want to neuter it, we *have* to implement it in that module (with a NOP). [1] The exception being ReaderZooming, but that only when in flip mode.
41 lines
1.1 KiB
Lua
41 lines
1.1 KiB
Lua
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
local Device = require("device")
|
|
local Event = require("ui/event")
|
|
local _ = require("gettext")
|
|
|
|
local ReaderRotation = InputContainer:extend{
|
|
current_rotation = 0,
|
|
}
|
|
|
|
function ReaderRotation:init()
|
|
if Device:hasKeyboard() then
|
|
self.key_events = {
|
|
-- these will all generate the same event, just with different arguments
|
|
RotateLeft = {
|
|
{ "J" },
|
|
event = "Rotate",
|
|
args = -90
|
|
},
|
|
RotateRight = {
|
|
{ "K" },
|
|
event = "Rotate",
|
|
args = 90
|
|
},
|
|
}
|
|
end
|
|
-- NOP our own gesture handling
|
|
self.ges_events = nil
|
|
end
|
|
|
|
function ReaderRotation:onGesture() end
|
|
|
|
--- @todo Reset rotation on new document, maybe on new page?
|
|
|
|
function ReaderRotation:onRotate(rotate_by)
|
|
self.current_rotation = (self.current_rotation + rotate_by) % 360
|
|
self.ui:handleEvent(Event:new("RotationUpdate", self.current_rotation))
|
|
return true
|
|
end
|
|
|
|
return ReaderRotation
|