X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdPanel.java;h=a65be7b1175dc42fc2920699ab96b43e73c0d773;hb=853624fb32058cccc544ae7d13af6ad4b0800b6c;hp=c84505b5de966d8b651c735b44a7075f1fd27259;hpb=be51e875b8c89a69629ecde5ec71aa9fc550b0fb;p=jalview.git diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index c84505b..a65be7b 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; @@ -316,42 +317,24 @@ public class IdPanel extends JPanel implements MouseListener, return; } - int seq = alignPanel.getSeqPanel().findSeq(e); - - if (e.isPopupTrigger()) + 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 mouseReleased on Windows + * (where isPopupTrigger() will answer true) + * NB isRightMouseButton is also true for Cmd-click on Mac + */ + if (SwingUtilities.isRightMouseButton(e) && !Platform.isAMac()) + { return; } if ((av.getSelectionGroup() == null) - || ((!e.isControlDown() && !e.isShiftDown()) && av + || (!jalview.util.Platform.isControlDown(e) && !e.isShiftDown() && av .getSelectionGroup() != null)) { av.setSelectionGroup(new SequenceGroup()); @@ -359,6 +342,7 @@ public class IdPanel extends JPanel implements MouseListener, av.getSelectionGroup().setEndRes(av.getAlignment().getWidth() - 1); } + int seq = alignPanel.getSeqPanel().findSeq(e); if (e.isShiftDown() && (lastid != -1)) { selectSeqs(lastid, seq); @@ -367,13 +351,48 @@ public class IdPanel extends JPanel implements MouseListener, { selectSeq(seq); } - // TODO is this addition ok here? + av.isSelectionGroupChanged(true); alignPanel.paintAlignment(true); } /** + * 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 @@ -440,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); + } } /**