From 3705d44c1e45abab9180067ed1e2862b9dea65d1 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 30 May 2016 15:45:20 +0100 Subject: [PATCH] JAL-2077 fix: convenience method and checks for CMD+Click to toggle selections --- src/jalview/appletgui/AnnotationLabels.java | 5 +++-- src/jalview/appletgui/IdPanel.java | 3 ++- src/jalview/gui/AnnotationLabels.java | 5 +++-- src/jalview/gui/IdPanel.java | 5 ++--- src/jalview/util/Platform.java | 10 ++++++++++ 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index c963202..487d130 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -743,7 +743,8 @@ public class AnnotationLabels extends Panel implements ActionListener, // we make a copy rather than edit the current selection if no // modifiers pressed // see Enhancement JAL-1557 - if (!(evt.isControlDown() || evt.isShiftDown())) + if (!(jalview.util.Platform.isControlDown(evt) || evt + .isShiftDown())) { sg = new SequenceGroup(sg); sg.clear(); @@ -751,7 +752,7 @@ public class AnnotationLabels extends Panel implements ActionListener, } else { - if (evt.isControlDown()) + if (jalview.util.Platform.isControlDown(evt)) { sg.addOrRemove(aa[selectedRow].sequenceRef, true); } diff --git a/src/jalview/appletgui/IdPanel.java b/src/jalview/appletgui/IdPanel.java index b4ed6d9..36c2199 100755 --- a/src/jalview/appletgui/IdPanel.java +++ b/src/jalview/appletgui/IdPanel.java @@ -351,7 +351,8 @@ public class IdPanel extends Panel implements MouseListener, } if ((av.getSelectionGroup() == null) - || ((!e.isControlDown() && !e.isShiftDown()) && av + || ((!jalview.util.Platform.isControlDown(e) && !e + .isShiftDown()) && av .getSelectionGroup() != null)) { av.setSelectionGroup(new SequenceGroup()); diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 68df498..8b9168a 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -833,7 +833,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, // we make a copy rather than edit the current selection if no // modifiers pressed // see Enhancement JAL-1557 - if (!(evt.isControlDown() || evt.isShiftDown())) + if (!(jalview.util.Platform.isControlDown(evt) || evt + .isShiftDown())) { sg = new SequenceGroup(sg); sg.clear(); @@ -841,7 +842,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, } else { - if (evt.isControlDown()) + if (jalview.util.Platform.isControlDown(evt)) { sg.addOrRemove(aa[selectedRow].sequenceRef, true); } diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index c84505b..61ddafb 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -349,10 +349,9 @@ public class IdPanel extends JPanel implements MouseListener, return; } - if ((av.getSelectionGroup() == null) - || ((!e.isControlDown() && !e.isShiftDown()) && av - .getSelectionGroup() != null)) + || (!jalview.util.Platform.isControlDown(e) + && !e.isShiftDown() && av.getSelectionGroup() != null)) { av.setSelectionGroup(new SequenceGroup()); av.getSelectionGroup().setStartRes(0); diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index b812feb..786f5bf 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -20,6 +20,9 @@ */ package jalview.util; +import java.awt.Toolkit; +import java.awt.event.MouseEvent; + /** * System platform information used by Applet and Application * @@ -74,4 +77,11 @@ public class Platform f.append(file.substring(lastp)); return f.toString(); } + + public static boolean isControlDown(MouseEvent e) + { + return (jalview.util.Platform.isAMac() ? (Toolkit.getDefaultToolkit() + .getMenuShortcutKeyMask() & e.getModifiers()) != 0 : e + .isControlDown()); + } } -- 1.7.10.2