From 60cc481239cf33d711931d489a215185474e69a1 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 31 Jan 2024 16:08:54 +0000 Subject: [PATCH] JAL-4375 Different way of getting mouse wheel movement for cross-platform (testing on macos and linux) sensitivity --- src/jalview/gui/SeqPanel.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 2634b7a..ff69d61 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -2235,12 +2235,17 @@ public class SeqPanel extends JPanel public void mouseWheelMoved(MouseWheelEvent e) { e.consume(); - double wheelRotation = e.getPreciseWheelRotation(); + double preciseWheelRotation = e.getPreciseWheelRotation(); + int wheelRotation = e.getWheelRotation(); + if (wheelRotation == 0 && Math.abs(preciseWheelRotation) > 0.1) + { + wheelRotation = 1; + } /* * scroll more for large (fast) mouse movements */ - int size = 1 + (int) Math.abs(wheelRotation); + int size = Math.abs(wheelRotation); if (wheelRotation > 0) { @@ -2253,7 +2258,7 @@ public class SeqPanel extends JPanel */ if (!ap.isScrolledFullyRight()) { - av.getRanges().scrollRight(true, size - 1); + av.getRanges().scrollRight(true, size); } } else @@ -2277,7 +2282,7 @@ public class SeqPanel extends JPanel /* * scroll left */ - av.getRanges().scrollRight(false, size - 1); + av.getRanges().scrollRight(false, size); } else { -- 1.7.10.2