mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
BookMap/PageBrowser: allow mousewheel scrolling
Also fix SDL to use sendEvent() instead of broadcastEvent(), so such BookMap scrolling doesn't also scroll pages in the book below.
This commit is contained in:
@@ -230,12 +230,12 @@ function Device:init()
|
||||
local fake_release_ev = Event:new("Gesture", fake_ges_release)
|
||||
if scrolled_y == down then
|
||||
fake_ges.direction = "north"
|
||||
UIManager:broadcastEvent(fake_pan_ev)
|
||||
UIManager:broadcastEvent(fake_release_ev)
|
||||
UIManager:sendEvent(fake_pan_ev)
|
||||
UIManager:sendEvent(fake_release_ev)
|
||||
elseif scrolled_y == up then
|
||||
fake_ges.direction = "south"
|
||||
UIManager:broadcastEvent(fake_pan_ev)
|
||||
UIManager:broadcastEvent(fake_release_ev)
|
||||
UIManager:sendEvent(fake_pan_ev)
|
||||
UIManager:sendEvent(fake_release_ev)
|
||||
end
|
||||
elseif ev.code == SDL_MULTIGESTURE then
|
||||
-- no-op for now
|
||||
|
||||
@@ -639,6 +639,12 @@ function BookMapWidget:init()
|
||||
range = self.dimen,
|
||||
}
|
||||
},
|
||||
Pan = { -- (for mousewheel scrolling support)
|
||||
GestureRange:new{
|
||||
ges = "pan",
|
||||
range = self.dimen,
|
||||
}
|
||||
},
|
||||
Tap = {
|
||||
GestureRange:new{
|
||||
ges = "tap",
|
||||
@@ -1608,6 +1614,16 @@ function BookMapWidget:onSwipe(arg, ges)
|
||||
end
|
||||
end
|
||||
|
||||
function BookMapWidget:onPan(arg, ges)
|
||||
if ges.mousewheel_direction then
|
||||
if ges.direction == "north" then
|
||||
return self:onScrollRowDown()
|
||||
elseif ges.direction == "south" then
|
||||
return self:onScrollRowUp()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BookMapWidget:onPinch(arg, ges)
|
||||
if self.overview_mode then
|
||||
return true
|
||||
|
||||
@@ -76,6 +76,12 @@ function PageBrowserWidget:init()
|
||||
range = self.dimen,
|
||||
}
|
||||
},
|
||||
Pan = { -- (for mousewheel scrolling support)
|
||||
GestureRange:new{
|
||||
ges = "pan",
|
||||
range = self.dimen,
|
||||
}
|
||||
},
|
||||
Tap = {
|
||||
GestureRange:new{
|
||||
ges = "tap",
|
||||
@@ -1176,6 +1182,17 @@ function PageBrowserWidget:onSwipe(arg, ges)
|
||||
end
|
||||
end
|
||||
|
||||
function PageBrowserWidget:onPan(arg, ges)
|
||||
if ges.mousewheel_direction then
|
||||
if ges.direction == "north" then
|
||||
self:onScrollRowDown()
|
||||
elseif ges.direction == "south" then
|
||||
self:onScrollRowUp()
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function PageBrowserWidget:onPinch(arg, ges)
|
||||
if ges.direction == "horizontal" then
|
||||
if self:updateNbCols(1, true) then
|
||||
|
||||
Reference in New Issue
Block a user