diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java index e51125d69b..be6dab1c4e 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/fieldpanel/FieldPanel.java @@ -1255,8 +1255,7 @@ public class FieldPanel extends JPanel final FieldLocation loc = new FieldLocation(cursorPosition); final Field field = cursorHandler.getCurrentField(); SystemUtilities.runSwingLater(() -> { - for (int i = 0; i < fieldMouseListeners.size(); i++) { - FieldMouseListener l = fieldMouseListeners.get(i); + for (FieldMouseListener l : fieldMouseListeners) { l.buttonPressed(loc, field, ev); } }); @@ -1278,8 +1277,7 @@ public class FieldPanel extends JPanel */ private void notifySelectionChanged(EventTrigger trigger) { FieldSelection currentSelection = new FieldSelection(selection); - for (int i = 0; i < selectionListeners.size(); i++) { - FieldSelectionListener l = selectionListeners.get(i); + for (FieldSelectionListener l : selectionListeners) { l.selectionChanged(currentSelection, trigger); } } @@ -1290,8 +1288,7 @@ public class FieldPanel extends JPanel private void notifyHighlightChanged() { FieldSelection currentSelection = new FieldSelection(highlight); - for (int i = 0; i < highlightListeners.size(); i++) { - FieldSelectionListener l = highlightListeners.get(i); + for (FieldSelectionListener l : highlightListeners) { l.selectionChanged(currentSelection, EventTrigger.API_CALL); } } @@ -1646,7 +1643,13 @@ public class FieldPanel extends JPanel } cursorHandler.setCursorPos(e.getX(), e.getY(), EventTrigger.GUI_ACTION); - if (!selectionHandler.isInProgress() && !didDrag) { + if (didDrag) { + // Send an event after the drag is finished. Event are suppressed while dragging, + // meaning that the above call to setCursorPos() will not have fired an event + // because the internal cursor position did not change during the mouse release. + cursorHandler.notifyCursorChanged(EventTrigger.GUI_ACTION); + } + else if (!selectionHandler.isInProgress()) { selectionHandler.clearSelection(); } selectionHandler.endSelectionSequence(); @@ -2111,8 +2114,7 @@ public class FieldPanel extends JPanel } FieldLocation currentLocation = new FieldLocation(cursorPosition); - for (int i = 0; i < cursorListeners.size(); i++) { - FieldLocationListener l = cursorListeners.get(i); + for (FieldLocationListener l : cursorListeners) { l.fieldLocationChanged(currentLocation, currentField, trigger); } @@ -2150,8 +2152,7 @@ public class FieldPanel extends JPanel private void notifyInputListeners(KeyEvent ev) { if (cursorOn) { - for (int i = 0; i < inputListeners.size(); i++) { - FieldInputListener l = inputListeners.get(i); + for (FieldInputListener l : inputListeners) { l.keyPressed(ev, cursorPosition.getIndex(), cursorPosition.fieldNum, cursorPosition.row, cursorPosition.col, currentField); }