mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[sdl] Add support arrow key for next/prev page (#5149)
Close: #4997 This PR add support arrow key and mouse scroll wheel for next/previous page. - Document in page mode: PageDown, Arrow down, Arrow right - go to next page PageUp, Arrow up, arrow left - go to prev page Mouse scroll wheel down - go to next page Mouse scroll wheel up - go to prev page - Document in scroll mode: PageDown, Arrow right - go to next page PageUp, Arrow, arrow left - go to prev page Arrow down - scroll document down Arrow up - scroll document up Mouse scroll wheel down - scroll document down Mouse scroll wheel up - scroll document up
This commit is contained in:
@@ -8,7 +8,6 @@ local ReaderPanning = require("apps/reader/modules/readerpanning")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local Input = Device.input
|
||||
local Screen = Device.screen
|
||||
local T = require("ffi/util").template
|
||||
|
||||
@@ -57,12 +56,12 @@ function ReaderRolling:init()
|
||||
self.key_events = {}
|
||||
if Device:hasKeys() then
|
||||
self.key_events.GotoNextView = {
|
||||
{ Input.group.PgFwd },
|
||||
{ {"RPgFwd", "LPgFwd", "Right" } },
|
||||
doc = "go to next view",
|
||||
event = "GotoViewRel", args = 1,
|
||||
}
|
||||
self.key_events.GotoPrevView = {
|
||||
{ Input.group.PgBack },
|
||||
{ { "RPgBack", "LPgBack", "Left" } },
|
||||
doc = "go to previous view",
|
||||
event = "GotoViewRel", args = -1,
|
||||
}
|
||||
@@ -446,6 +445,9 @@ function ReaderRolling:onPan(_, ges)
|
||||
elseif ges.direction == "south" then
|
||||
self:_gotoPos(self.current_pos - ges[distance_type])
|
||||
end
|
||||
--this is only use when mouse wheel is used
|
||||
elseif ges.mousewheel_direction and self.view.view_mode == "page" then
|
||||
UIManager:broadcastEvent(Event:new("GotoViewRel", -1 * ges.mousewheel_direction))
|
||||
end
|
||||
return true
|
||||
end
|
||||
@@ -629,8 +631,11 @@ function ReaderRolling:onGotoViewRel(diff)
|
||||
end
|
||||
|
||||
function ReaderRolling:onPanning(args, _)
|
||||
if self.view.view_mode ~= "scroll" then return end
|
||||
local _, dy = unpack(args)
|
||||
if self.view.view_mode ~= "scroll" then
|
||||
UIManager:broadcastEvent(Event:new("GotoViewRel", dy))
|
||||
return
|
||||
end
|
||||
self:_gotoPos(self.current_pos + dy * self.panning_steps.normal)
|
||||
self.xpointer = self.ui.document:getXPointer()
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user