Skip to content

Commit

Permalink
fix mouse wheel delta in Qt 5 (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed May 12, 2016
1 parent 8161d7d commit 69130e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion rqt_bag/src/rqt_bag/timeline_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,11 @@ def on_mouse_up(self, event):
self.scene().update()

def on_mousewheel(self, event):
dz = event.delta() / 120.0
try:
delta = event.angleDelta().y()
except AttributeError:
delta = event.delta()
dz = delta / 120.0
self.zoom_timeline(1.0 - dz * 0.2)

def on_mouse_move(self, event):
Expand Down
5 changes: 4 additions & 1 deletion rqt_graph/src/rqt_graph/interactive_graphics_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def mouseMoveEvent(self, mouse_event):

def wheelEvent(self, wheel_event):
if wheel_event.modifiers() == Qt.NoModifier:
delta = wheel_event.delta()
try:
delta = wheel_event.angleDelta().y()
except AttributeError:
delta = wheel_event.delta()
delta = max(min(delta, 480), -480)
mouse_before_scale_in_scene = self.mapToScene(wheel_event.pos())

Expand Down
6 changes: 5 additions & 1 deletion rqt_plot/src/rqt_plot/data_plot/qwt_data_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ def wheelEvent(self, event): # mouse wheel zooms the y-axis
# y position of pointer in graph coordinates
canvas_y = event.y() - self.canvas().y()

zoom_factor = max(-0.6, min(0.6, (event.delta() / 120) / 6.0))
try:
delta = event.angleDelta().y()
except AttributeError:
delta = event.delta()
zoom_factor = max(-0.6, min(0.6, (delta / 120) / 6.0))
delta_y = (self.canvas().height() / 2.0) - canvas_y
self.move_canvas(0, zoom_factor * delta_y * 1.0225)

Expand Down

0 comments on commit 69130e5

Please sign in to comment.