From 0d74306f282be2d15eeb5d8de53a949c0124a0a5 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 1 Sep 2016 12:07:44 +0100 Subject: [PATCH] JAL-2077 do nothing in mousePressed if right button down (on Windows) --- src/jalview/gui/AnnotationPanel.java | 5 ++++- src/jalview/gui/IdPanel.java | 8 ++++---- src/jalview/gui/ScalePanel.java | 18 +++++++++--------- src/jalview/gui/SeqPanel.java | 11 +++++++++++ src/jalview/gui/TreeCanvas.java | 28 ++++++++++++++++++++++++++-- 5 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 04590ba..bd903b3 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -543,7 +543,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } ap.getScalePanel().mousePressed(evt); - } /** @@ -607,6 +606,10 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, mouseDragging = false; ap.getScalePanel().mouseReleased(evt); + /* + * isPopupTrigger is set in mouseReleased on Windows + * (in mousePressed on Mac) + */ if (evt.isPopupTrigger() && activeRow != -1) { showPopupMenu(evt.getY(), evt.getX()); diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index 2aa7bf5..08e5116 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -26,7 +26,6 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.io.SequenceAnnotationReport; import jalview.util.MessageManager; -import jalview.util.Platform; import jalview.util.UrlLink; import jalview.viewmodel.AlignmentViewport; @@ -320,14 +319,15 @@ public class IdPanel extends JPanel implements MouseListener, if (e.isPopupTrigger()) // Mac reports this in mousePressed { showPopupMenu(e); - return; } + /* - * defer right-mouse click handling to mouse up on Mac + * defer right-mouse click handling to mouseReleased on Windows * (where isPopupTrigger() will answer true) + * NB isRightMouseButton is also true for Cmd-click on Mac */ - if (SwingUtilities.isRightMouseButton(e) && !Platform.isAMac()) + if (SwingUtilities.isRightMouseButton(e)) { return; } diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 2efcbff..0aa2459 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -101,15 +101,6 @@ public class ScalePanel extends JPanel implements MouseMotionListener, @Override public void mousePressed(MouseEvent evt) { - /* - * defer right-mouse click handling to mouse up on Mac - * (where isPopupTrigger() will answer true) - */ - if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac()) - { - return; - } - int x = (evt.getX() / av.getCharWidth()) + av.getStartRes(); final int res; @@ -134,6 +125,15 @@ public class ScalePanel extends JPanel implements MouseMotionListener, { rightMouseButtonPressed(evt, res); } + else if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac()) + { + /* + * defer right-mouse click handling to mouse up on Windows + * (where isPopupTrigger() will answer true) + * but accept Cmd-click on Mac which passes isRightMouseButton + */ + return; + } else { leftMouseButtonPressed(evt, res); diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 46ea202..bd8959d 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -43,6 +43,7 @@ import jalview.structure.VamsasSource; import jalview.util.Comparison; import jalview.util.MappingUtils; import jalview.util.MessageManager; +import jalview.util.Platform; import jalview.viewmodel.AlignmentViewport; import java.awt.BorderLayout; @@ -1630,6 +1631,16 @@ public class SeqPanel extends JPanel implements MouseListener, return; } + /* + * defer right-mouse click handling to mouseReleased on Windows + * (where isPopupTrigger() will answer true) + * NB isRightMouseButton is also true for Cmd-click on Mac + */ + if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac()) + { + return; + } + if (av.cursorMode) { seqCanvas.cursorX = findRes(evt); diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index b300b5b..254d032 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -59,6 +59,7 @@ import java.util.Vector; import javax.swing.JColorChooser; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; /** @@ -792,6 +793,11 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, { return; } + + /* + * isPopupTrigger is set on mouseReleased / + * mouseClicked on Windows + */ if (evt.isPopupTrigger()) { chooseSubtreeColour(); @@ -879,9 +885,27 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, public void mousePressed(MouseEvent e) { av.setCurrentTree(tree); - if (highlightNode != null && e.isPopupTrigger()) + + /* + * isPopupTrigger is set for mousePressed (Mac) + * or mouseReleased / mouseClicked (Windows) + */ + if (e.isPopupTrigger()) + { + if (highlightNode != null) + { + chooseSubtreeColour(); + } + return; + } + + /* + * defer right-click handling on Windows to + * mouseClicked; this also matches Cmd-click on Mac + * which should do nothing here + */ + if (SwingUtilities.isRightMouseButton(e)) { - chooseSubtreeColour(); return; } -- 1.7.10.2