Skip to content

Commit a68aaf0

Browse files
committed
Right-clicking a dataset selector now selects the clicked row before showing the context menu, if not selected already.
1 parent d5fdb92 commit a68aaf0

File tree

1 file changed

+12
-4
lines changed
  • EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/control

1 file changed

+12
-4
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/control/DataSetSelector.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,25 @@ public TableCellRenderer getCellRenderer(int row, int column) {
270270
table.addMouseListener(new MouseAdapter() {
271271
@Override
272272
public void mousePressed(MouseEvent e) {
273+
final int row = table.rowAtPoint(e.getPoint());
273274
final boolean isMac = LookAndFeelUtil.isMac();
274275

275-
// COMMAND button down on MacOS (or CONTROL button down on another OS) or SHIFT?
276-
if ((isMac && e.isMetaDown()) || (!isMac && e.isControlDown()) || e.isShiftDown())
276+
// COMMAND button down on MacOS (or CONTROL button down on another OS)?
277+
if ((isMac && e.isMetaDown()) || (!isMac && e.isControlDown())) {
278+
// Right-click must select the row, if not selected already,
279+
// because the context menu (activated by right-click) acts on the selected rows
280+
if (!table.isRowSelected(row))
281+
table.setRowSelectionInterval(row, row);
282+
283+
return;
284+
}
285+
286+
if (e.isShiftDown())
277287
return; // Ignore!
278288

279289
final int col = table.columnAtPoint(e.getPoint());
280290

281291
if (col == SELECTED_COL_IDX) {
282-
final int row = table.rowAtPoint(e.getPoint());
283-
284292
// Restore previous multiple-row selection first
285293
if (previousSelectedRows != null && previousSelectedRows.contains(row)) {
286294
for (int i : previousSelectedRows)

0 commit comments

Comments
 (0)