JAL-2077 do nothing in mousePressed if right button down (on Windows)
[jalview.git] / src / jalview / gui / TreeCanvas.java
index b300b5b..254d032 100755 (executable)
@@ -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;
     }