Merge remote-tracking branch 'origin/GT-2383_dev747368_tree_focus_after_click_same_node'

This commit is contained in:
Ryan Kurtz
2019-08-07 08:36:11 -04:00
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +25,7 @@ import javax.swing.tree.TreeSelectionModel;
public class JTreeMouseListenerDelegate extends MouseAdapter {
private final Set<MouseListener> listeners = new CopyOnWriteArraySet<MouseListener>();
private final Set<MouseListener> listeners = new CopyOnWriteArraySet<>();
private final JTree tree;
private boolean consumedPressed;
@@ -87,6 +86,10 @@ public class JTreeMouseListenerDelegate extends MouseAdapter {
if (isPotentialDragSelection(e)) {
e.consume();
consumedPressed = true;
// ensure the tree has focus in this case, since we consumed the event, which can
// prevent the normal focus updating done by Swing
fixFocus();
}
else {
consumedPressed = false;
@@ -94,6 +97,12 @@ public class JTreeMouseListenerDelegate extends MouseAdapter {
fireMousePressed(e);
}
private void fixFocus() {
if (!tree.hasFocus()) {
tree.requestFocus();
}
}
@Override
public void mouseClicked(MouseEvent e) {
handlePopupTrigger(e);