mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
Merge remote-tracking branch 'origin/GT-2383_dev747368_tree_focus_after_click_same_node'
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
/* ###
|
/* ###
|
||||||
* IP: GHIDRA
|
* IP: GHIDRA
|
||||||
* REVIEWED: YES
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
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 final JTree tree;
|
||||||
|
|
||||||
private boolean consumedPressed;
|
private boolean consumedPressed;
|
||||||
@@ -87,6 +86,10 @@ public class JTreeMouseListenerDelegate extends MouseAdapter {
|
|||||||
if (isPotentialDragSelection(e)) {
|
if (isPotentialDragSelection(e)) {
|
||||||
e.consume();
|
e.consume();
|
||||||
consumedPressed = true;
|
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 {
|
else {
|
||||||
consumedPressed = false;
|
consumedPressed = false;
|
||||||
@@ -94,6 +97,12 @@ public class JTreeMouseListenerDelegate extends MouseAdapter {
|
|||||||
fireMousePressed(e);
|
fireMousePressed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fixFocus() {
|
||||||
|
if (!tree.hasFocus()) {
|
||||||
|
tree.requestFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
handlePopupTrigger(e);
|
handlePopupTrigger(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user