Skip to content

Commit 0a88816

Browse files
author
MatthieuMeert
committed
horizontal scroll using shift+scroll works with webkit backend
1 parent 7cd0263 commit 0a88816

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

src/timeline/js/controllers.js

+7
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,13 @@ App.controller("TimelineCtrl", function ($scope) {
284284
scrolling_tracks.scrollLeft(new_cursor_x);
285285
};
286286

287+
// Scroll the timeline horizontally of a certain amount (scrol_value)
288+
$scope.scrollLeft = function (scroll_value) {
289+
var scrolling_tracks = $("#scrolling_tracks");
290+
var horz_scroll_offset = scrolling_tracks.scrollLeft();
291+
scrolling_tracks.scrollLeft(horz_scroll_offset + scroll_value);
292+
};
293+
287294
// Center the timeline on a given time position
288295
$scope.centerOnTime = function (centerTime) {
289296
// Get the width of the timeline

src/windows/views/webview.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -2783,14 +2783,17 @@ def update_zoom(self, newValue):
27832783

27842784
# Capture wheel event to alter zoom slider control
27852785
def wheelEvent(self, event):
2786-
if int(QCoreApplication.instance().keyboardModifiers() & Qt.ControlModifier) > 0:
2786+
if event.modifiers() & Qt.ControlModifier:
2787+
event.accept()
2788+
zoom = self.window.sliderZoom
27872789
# For each 120 (standard scroll unit) adjust the zoom slider
27882790
tick_scale = 120
27892791
steps = int(event.angleDelta().y() / tick_scale)
2790-
self.window.sliderZoom.setValue(self.window.sliderZoom.value() - self.window.sliderZoom.pageStep() * steps)
2792+
delta = zoom.pageStep() * steps
2793+
log.debug("Zooming by %d steps", -steps)
2794+
zoom.setValue(zoom.value() - delta)
27912795
else:
2792-
# Otherwise pass on to implement default functionality (scroll in QWebEngineView)
2793-
super(type(self), self).wheelEvent(event)
2796+
super().wheelEvent(event)
27942797

27952798
# An item is being dragged onto the timeline (mouse is entering the timeline now)
27962799
def dragEnterEvent(self, event):

src/windows/views/webview_backend/webkit.py

+17
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,20 @@ def keyPressEvent(self, event):
123123
else:
124124
# Ignore most keypresses
125125
event.ignore()
126+
127+
def wheelEvent(self, event):
128+
""" Mousewheel scrolling """
129+
if event.modifiers() & Qt.ShiftModifier:
130+
event.accept()
131+
frame = self.page().mainFrame()
132+
# Compute scroll offset from wheel motion
133+
tick_scale = 120
134+
steps = int(event.angleDelta().y() / tick_scale)
135+
delta = -(steps * 100)
136+
log.debug("Scrolling horizontally by %d pixels", delta)
137+
# Update the scroll position using AngularJS
138+
js = f"$('body').scope().scrollLeft({delta});"
139+
frame.evaluateJavaScript(js)
140+
else:
141+
super().wheelEvent(event)
142+

0 commit comments

Comments
 (0)