Changeset 19720 in josm for trunk/src/org
- Timestamp:
- 2026-11-29T16:53:50+01:00 (3 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r19633 r19720 13 13 import java.awt.event.KeyEvent; 14 14 import java.awt.event.MouseEvent; 15 import java.awt.event.WindowAdapter; 16 import java.awt.event.WindowEvent; 17 import java.awt.event.WindowFocusListener; 15 18 import java.util.ArrayList; 16 19 import java.util.Collection; … … 147 150 private final ParallelWayLayer temporaryLayer = new ParallelWayLayer(); 148 151 152 /** #25012: a drag cannot continue once JOSM loses the focus, as the mouse release may go to another window */ 153 private final WindowFocusListener focusListener = new WindowAdapter() { 154 @Override 155 public void windowLostFocus(WindowEvent e) { 156 cancelDrag(); 157 } 158 }; 159 149 160 /** 150 161 * Constructs a new {@code ParallelWayAction}. … … 176 187 // Needed to update the mouse cursor if modifiers are changed when the mouse is motionless 177 188 MainApplication.getMap().keyDetector.addModifierExListener(this); 189 if (MainApplication.getMainFrame() != null) { 190 MainApplication.getMainFrame().addWindowFocusListener(focusListener); 191 } 178 192 sourceWays = new LinkedHashSet<>(getLayerManager().getEditDataSet().getSelectedWays()); 179 193 for (Way w : sourceWays) { … … 191 205 map.statusLine.setDist(-1); 192 206 map.keyDetector.removeModifierExListener(this); 207 if (MainApplication.getMainFrame() != null) { 208 MainApplication.getMainFrame().removeWindowFocusListener(focusListener); 209 } 193 210 removeWayHighlighting(sourceWays); 194 211 pWays = null; … … 282 299 return; 283 300 301 // #25012: the release ending the previous drag never arrived, drop that drag and start afresh 302 cancelDrag(); 303 284 304 if (!sanityCheck()) 285 305 return; … … 306 326 updateModifiersState(e.getModifiersEx()); 307 327 // Other buttons are off limit, but we still get events. 308 if (e.getButton() != MouseEvent.BUTTON1) 328 // Ignore the release of a press that was not accepted or whose drag was cancelled. 329 if (e.getButton() != MouseEvent.BUTTON1 || !mouseIsDown) 309 330 return; 310 331 … … 516 537 } 517 538 539 /** 540 * Cancels the drag in progress, if any. Nothing has been changed yet, since the parallel ways are only created 541 * when the mouse is released. 542 */ 543 private void cancelDrag() { 544 if (mode == Mode.DRAGGING) { 545 pWays = null; 546 helperSegment = null; 547 setMode(Mode.NORMAL); 548 MainApplication.getMap().statusLine.setDist(-1); 549 temporaryLayer.invalidate(); 550 } 551 resetMouseTrackingState(); 552 } 553 518 554 private void resetMouseTrackingState() { 519 555 mouseIsDown = false;
Note:
See TracChangeset
for help on using the changeset viewer.
