Changeset 1412 in josm


Ignore:
Timestamp:
2009-02-15T21:29:01+01:00 (15 years ago)
Author:
stoecker
Message:

close #2179

Location:
trunk/src/org/openstreetmap/josm/actions/mapmode
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r1409 r1412  
    7474    private boolean drawTargetCursor;
    7575    private Point mousePos;
     76    private Point oldMousePos;
    7677    private Color selectedColor;
    7778
     
    247248        if(!Main.map.mapView.isDrawableLayer())
    248249            return;
    249         if(e.getClickCount() > 1) {
     250       
     251        if(e.getClickCount() > 1 && mousePos != null && mousePos.equals(oldMousePos)) {
    250252            // A double click equals "user clicked last node again, finish way"
     253            // Change draw tool only if mouse position is nearly the same, as
     254            // otherwise fast clicks will count as a double click
    251255            lastUsedNode = null;
    252256            wayIsFinished = true;
     257
    253258            Main.map.selectSelectTool(true);
    254259            return;
    255260        }
     261        oldMousePos = mousePos;
     262       
    256263        // we copy ctrl/alt/shift from the event just in case our global
    257264        // AWTEvent didn't make it through the security manager. Unclear
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r1405 r1412  
    1010import java.awt.event.KeyEvent;
    1111import java.awt.event.MouseEvent;
     12import java.util.ArrayList;
    1213import java.util.Collection;
    1314import java.util.Collections;
    1415import java.util.LinkedList;
     16import java.util.List;
    1517
    1618import javax.swing.JOptionPane;
     
    5759    private long mouseDownTime = 0;
    5860    private boolean didMove = false;
     61    private boolean cancelDrawMode = false;
    5962    Node virtualNode = null;
    6063    WaySegment virtualWay = null;
     
    142145     */
    143146    @Override public void mouseDragged(MouseEvent e) {
     147        cancelDrawMode = true;
    144148        if (mode == Mode.select) return;
    145149
     
    279283     */
    280284    @Override public void mousePressed(MouseEvent e) {
     285        cancelDrawMode = false;
    281286        if (! (Boolean)this.getValue("active")) return;
    282287        if (e.getButton() != MouseEvent.BUTTON1)
     
    329334        if (mode == Mode.select) {
    330335            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) {
    332339                Main.map.selectDrawTool(true);
    333340                return;
     341            }
    334342        }
    335343        restoreCursor();
     
    342350                    Main.map.mapView.getNearestCollection(e.getPoint()),
    343351                    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                }
    344365            } else {
    345366                Collection<OsmPrimitive> selection = Main.ds.getSelected();
     
    402423        }
    403424    }
    404    
     425
    405426    @Override public boolean layerIsSupported(Layer l) {
    406427        return l instanceof OsmDataLayer;
Note: See TracChangeset for help on using the changeset viewer.