Merge remote-tracking branch

'origin/GP-5618-dragonmacher-table-popup-fix--SQUASHED' (Closes #7902)
This commit is contained in:
Ryan Kurtz 2025-04-28 14:14:43 -04:00
commit fb54675cfc
4 changed files with 35 additions and 7 deletions

View file

@ -166,6 +166,7 @@ public class DockableComponent extends JPanel implements ContainerListener {
if (e.isPopupTrigger() && withinBounds) {
PopupMenuContext popupContext = new PopupMenuContext(e);
actionMgr.showPopupMenu(placeholder, popupContext);
e.consume();
}
}
@ -328,8 +329,27 @@ public class DockableComponent extends JPanel implements ContainerListener {
}
if (comp.isFocusable()) {
installPopupListenerFirst(comp);
}
}
/**
* Remove and re-add all mouse listeners so our popup listener can go first. This allows our
* popup listener to consume the event, preventing Java UI listeners from changing the table
* selection when the user is performing a Ctrl-Mouse click on the Mac.
*
* @param comp the component
*/
private void installPopupListenerFirst(Component comp) {
comp.removeMouseListener(popupListener);
MouseListener[] listeners = comp.getMouseListeners();
for (MouseListener l : listeners) {
comp.removeMouseListener(l);
}
comp.addMouseListener(popupListener);
for (MouseListener l : listeners) {
comp.addMouseListener(l);
}
}

View file

@ -104,7 +104,7 @@ public class GTable extends JTable {
private MouseListener selectRowListener = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
if (e.isPopupTrigger()) {
int row = rowAtPoint(e.getPoint());
if (row >= 0) {
if (!isRowSelected(row)) {

View file

@ -1734,6 +1734,14 @@ public class GTree extends JPanel implements BusyListener {
}
}
@Override
public synchronized MouseListener[] getMouseListeners() {
if (mouseListenerDelegate == null) {
return super.getMouseListeners();
}
return mouseListenerDelegate.getMouseListeners();
}
@Override
public void removeSelectionPath(TreePath path) {
// Called by the UI to add/remove selections--mark it as a user event.