Ticket #2179: PotlatchDrawing AddDblClick FixRectangle.patch
| File PotlatchDrawing AddDblClick FixRectangle.patch, 3.1 KB (added by , 17 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
9 9 import java.awt.event.ActionEvent; 10 10 import java.awt.event.KeyEvent; 11 11 import java.awt.event.MouseEvent; 12 import java.util.ArrayList; 12 13 import java.util.Collection; 13 14 import java.util.Collections; 14 15 import java.util.LinkedList; 16 import java.util.List; 15 17 16 18 import javax.swing.JOptionPane; 17 19 … … 56 58 private Mode mode = null; 57 59 private long mouseDownTime = 0; 58 60 private boolean didMove = false; 61 private boolean cancelDrawMode = false; 59 62 Node virtualNode = null; 60 63 WaySegment virtualWay = null; 61 64 SequenceCommand virtualCmds = null; … … 141 144 * mouse (which will become selected). 142 145 */ 143 146 @Override public void mouseDragged(MouseEvent e) { 147 cancelDrawMode = true; 144 148 if (mode == Mode.select) return; 145 149 146 150 // do not count anything as a move if it lasts less than 100 milliseconds. … … 278 282 * cursor to movement. 279 283 */ 280 284 @Override public void mousePressed(MouseEvent e) { 285 cancelDrawMode = false; 281 286 if (! (Boolean)this.getValue("active")) return; 282 287 if (e.getButton() != MouseEvent.BUTTON1) 283 288 return; … … 328 333 @Override public void mouseReleased(MouseEvent e) { 329 334 if (mode == Mode.select) { 330 335 selectionManager.unregister(Main.map.mapView); 331 if(Main.ds.getSelected().size() == 0) 336 337 // Select Draw Tool if no selection has been made 338 if(Main.ds.getSelected().size() == 0 && !cancelDrawMode) { 332 339 Main.map.selectDrawTool(true); 333 340 return; 341 } 334 342 } 335 343 restoreCursor(); 336 344 … … 341 349 selectPrims( 342 350 Main.map.mapView.getNearestCollection(e.getPoint()), 343 351 shift, ctrl); 352 353 // If the user double-clicked a node, change to draw mode 354 List<OsmPrimitive> sel = new ArrayList<OsmPrimitive>(Main.ds.getSelected()); 355 if(e.getClickCount() >=2 && sel.size() == 1 && sel.get(0) instanceof Node) { 356 // We need to do it like this as otherwise drawAction will see a double 357 // click and switch back to SelectMode 358 Main.worker.execute(new Runnable(){ 359 public void run() { 360 Main.map.selectDrawTool(true); 361 } 362 }); 363 return; 364 } 344 365 } else { 345 366 Collection<OsmPrimitive> selection = Main.ds.getSelected(); 346 367 if (ctrl) { … … 401 422 return tr("Move objects by dragging; Shift to add to selection (Ctrl to remove); Shift-Ctrl to rotate selected; or change selection"); 402 423 } 403 424 } 404 425 405 426 @Override public boolean layerIsSupported(Layer l) { 406 427 return l instanceof OsmDataLayer; 407 428 }
