Menu, DictQuickLookup, TextViewer: allow mousewheel scrolling (#11525)

We also need to catch it in TrapWidget so we can
interrupt Wikipedia articles images loading.
reviewable/pr11530/r1
poire-z 2 months ago committed by GitHub
parent c8f39c3841
commit c65d128032
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1239,6 +1239,19 @@ function DictQuickLookup:onForwardingPan(arg, ges)
end
function DictQuickLookup:onForwardingPanRelease(arg, ges)
-- Allow scrolling with the mousewheel
if ges.from_mousewheel and ges.relative and ges.relative.y then
if ges.relative.y < 0 then
if not self.definition_widget[1]:onScrollDown() then
self:onReadNextResult()
end
elseif ges.relative.y > 0 then
if not self.definition_widget[1]:onScrollUp() then
self:onReadPrevResult()
end
end
return true
end
-- We can forward onMovablePanRelease() does enough checks
return self.movable:onMovablePanRelease(arg, ges)
end

@ -931,6 +931,12 @@ function Menu:init()
}
}
end
self.ges_events.Pan = { -- (for mousewheel scrolling support)
GestureRange:new{
ges = "pan",
range = self.dimen,
}
}
self.ges_events.Close = self.on_close_ges
if not Device:hasKeyboard() then
@ -1386,6 +1392,17 @@ function Menu:onSwipe(arg, ges_ev)
end
end
function Menu:onPan(arg, ges_ev)
if ges_ev.mousewheel_direction then
if ges_ev.direction == "north" then
self:onNextPage()
elseif ges_ev.direction == "south" then
self:onPrevPage()
end
end
return true
end
function Menu:onMultiSwipe(arg, ges_ev)
-- For consistency with other fullscreen widgets where swipe south can't be
-- used to close and where we then allow any multiswipe to close, allow any

@ -444,6 +444,15 @@ function TextViewer:onForwardingPan(arg, ges)
end
function TextViewer:onForwardingPanRelease(arg, ges)
-- Allow scrolling with the mousewheel
if ges.from_mousewheel and ges.relative and ges.relative.y then
if ges.relative.y < 0 then
self.scroll_text_w:scrollText(1)
elseif ges.relative.y > 0 then
self.scroll_text_w:scrollText(-1)
end
return true
end
-- We can forward onMovablePanRelease() does enough checks
return self.movable:onMovablePanRelease(arg, ges)
end

@ -54,6 +54,9 @@ function TrapWidget:init()
SwipeDismiss = {
GestureRange:new{ ges = "swipe", range = full_screen, }
},
PanReleaseDismiss = { -- emitted on mousewheel event
GestureRange:new{ ges = "pan_release", range = full_screen, }
},
}
end
if self.text then
@ -139,6 +142,10 @@ function TrapWidget:onSwipeDismiss(_, ev)
return self:_dismissAndResend("Gesture", ev)
end
function TrapWidget:onPanReleaseDismiss(_, ev)
return self:_dismissAndResend("Gesture", ev)
end
function TrapWidget:onShow()
if self.frame then
UIManager:setDirty(self, function()

Loading…
Cancel
Save