X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdPanel.java;h=2aa7bf5cf39fe998dd887db1e668dfcf7792241a;hb=99e8c69c6a6f4ea5e63d61b40376bb98fb1ae9a7;hp=eb5faa185576395dd13329ef0b16710ebb75b74f;hpb=2672f9a72ffb8ffaf4b48a08e64de7f3d83ce061;p=jalview.git diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index eb5faa1..2aa7bf5 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -26,6 +26,7 @@ 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; @@ -193,6 +194,8 @@ public class IdPanel extends JPanel implements MouseListener, */ if (e.getClickCount() < 2 || SwingUtilities.isRightMouseButton(e)) { + // reinstate isRightMouseButton check to ignore mouse-related popup events + // note - this does nothing on default MacBookPro force-trackpad config! return; } @@ -314,49 +317,31 @@ public class IdPanel extends JPanel implements MouseListener, return; } - int seq = alignPanel.getSeqPanel().findSeq(e); - - if (SwingUtilities.isRightMouseButton(e)) + if (e.isPopupTrigger()) // Mac reports this in mousePressed { - Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq); - // build a new links menu based on the current links + any non-positional - // features - Vector nlinks = new Vector( - Preferences.sequenceURLLinks); - SequenceFeature sfs[] = sq == null ? null : sq.getSequenceFeatures(); - if (sfs != null) - { - for (SequenceFeature sf : sfs) - { - if (sf.begin == sf.end && sf.begin == 0) - { - if (sf.links != null && sf.links.size() > 0) - { - for (int l = 0, lSize = sf.links.size(); l < lSize; l++) - { - nlinks.addElement(sf.links.elementAt(l)); - } - } - } - } - } - - PopupMenu pop = new PopupMenu(alignPanel, sq, nlinks, - Preferences.getGroupURLLinks()); - pop.show(this, e.getX(), e.getY()); + showPopupMenu(e); return; } + /* + * defer right-mouse click handling to mouse up on Mac + * (where isPopupTrigger() will answer true) + */ + if (SwingUtilities.isRightMouseButton(e) && !Platform.isAMac()) + { + 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); av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1); } + int seq = alignPanel.getSeqPanel().findSeq(e); if (e.isShiftDown() && (lastid != -1)) { selectSeqs(lastid, seq); @@ -372,6 +357,42 @@ public class IdPanel extends JPanel implements MouseListener, } /** + * Build and show the popup-menu at the right-click mouse position + * + * @param e + */ + void showPopupMenu(MouseEvent e) + { + int seq2 = alignPanel.getSeqPanel().findSeq(e); + Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq2); + // build a new links menu based on the current links + any non-positional + // features + Vector nlinks = new Vector( + Preferences.sequenceURLLinks); + SequenceFeature sfs[] = sq == null ? null : sq.getSequenceFeatures(); + if (sfs != null) + { + for (SequenceFeature sf : sfs) + { + if (sf.begin == sf.end && sf.begin == 0) + { + if (sf.links != null && sf.links.size() > 0) + { + for (int l = 0, lSize = sf.links.size(); l < lSize; l++) + { + nlinks.addElement(sf.links.elementAt(l)); + } + } + } + } + } + + PopupMenu pop = new PopupMenu(alignPanel, sq, nlinks, + Preferences.getGroupURLLinks()); + pop.show(this, e.getX(), e.getY()); + } + + /** * Toggle whether the sequence is part of the current selection group. * * @param seq @@ -438,6 +459,11 @@ public class IdPanel extends JPanel implements MouseListener, PaintRefresher.Refresh(this, av.getSequenceSetId()); // always send selection message when mouse is released av.sendSelection(); + + if (e.isPopupTrigger()) // Windows reports this in mouseReleased + { + showPopupMenu(e); + } } /**