From ce21c3bd8e2aa1937541b60cc775ffa99229feaf Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 18 Aug 2016 11:08:23 +0100 Subject: [PATCH] JAL-2077 handling Cmd-click in scale panel for Mac / Windows --- src/jalview/gui/ScalePanel.java | 3 ++- src/jalview/util/Platform.java | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index e231c6f..316b6be 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -26,6 +26,7 @@ import jalview.datamodel.SequenceI; import jalview.renderer.ScaleRenderer; import jalview.renderer.ScaleRenderer.ScaleMark; import jalview.util.MessageManager; +import jalview.util.Platform; import java.awt.Color; import java.awt.FontMetrics; @@ -221,7 +222,7 @@ public class ScalePanel extends JPanel implements MouseMotionListener, */ protected void leftMouseButtonPressed(MouseEvent evt, final int res) { - if (!evt.isControlDown() && !evt.isShiftDown()) + if (!Platform.isControlDown(evt) && !evt.isShiftDown()) { av.getColumnSelection().clear(); } diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index 786f5bf..85a27f6 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -78,10 +78,21 @@ public class Platform return f.toString(); } + /** + * Answers true if the mouse event has Meta-down (on Mac) or Ctrl-down (on + * other o/s) + * + * @param e + * @return + */ public static boolean isControlDown(MouseEvent e) { - return (jalview.util.Platform.isAMac() ? (Toolkit.getDefaultToolkit() - .getMenuShortcutKeyMask() & e.getModifiers()) != 0 : e - .isControlDown()); + if (isAMac()) + { + return (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() & e + .getModifiers()) != 0; + // could we use e.isMetaDown() here? + } + return e.isControlDown(); } } -- 1.7.10.2