From: Jim Procter Date: Mon, 30 May 2016 14:45:20 +0000 (+0100) Subject: JAL-2077 fix: convenience method and checks for CMD+Click to toggle selections X-Git-Tag: Release_2_10_0~196^2~3^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3705d44c1e45abab9180067ed1e2862b9dea65d1;p=jalview.git JAL-2077 fix: convenience method and checks for CMD+Click to toggle selections --- 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()); + } }