Changeset 1454 in josm for trunk/src


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

fix #2242. CTRL now toggles selection instead of only deselecting

File:
1 edited

Legend:

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

    r1441 r1454  
    197197
    198198            Main.main.undoRedo.add(new SequenceCommand(text, virtualCmds));
    199             selectPrims(Collections.singleton((OsmPrimitive)virtualNode), false, false);
     199            selectPrims(Collections.singleton((OsmPrimitive)virtualNode), false, false, false);
    200200            virtualWays.clear();
    201201            virtualNode = null;
     
    333333
    334334        if (ctrl && shift) {
    335             if (Main.ds.getSelected().isEmpty()) selectPrims(osmColl, true, false);
     335            if (Main.ds.getSelected().isEmpty()) selectPrims(osmColl, true, false, false);
    336336            mode = Mode.rotate;
    337337            setCursor(ImageProvider.getCursor("rotate", null));
     
    343343            selectPrims(osmColl,
    344344                shift || Main.ds.getSelected().containsAll(osmColl),
    345                 ctrl);
     345                ctrl, false);
    346346            mode = Mode.move;
    347347        } else {
     
    391391                selectPrims(
    392392                    Main.map.mapView.getNearestCollection(e.getPoint()),
    393                     shift, ctrl);
     393                    shift, ctrl, true);
    394394
    395395                // If the user double-clicked a node, change to draw mode
     
    433433
    434434    public void selectionEnded(Rectangle r, boolean alt, boolean shift, boolean ctrl) {
    435         selectPrims(selectionManager.getObjectsInRectangle(r, alt), shift, ctrl);
    436     }
    437 
    438     public void selectPrims(Collection<OsmPrimitive> selectionList, boolean shift, boolean ctrl) {
    439         if (shift && ctrl)
     435        selectPrims(selectionManager.getObjectsInRectangle(r, alt), shift, ctrl, false);
     436    }
     437
     438    public void selectPrims(Collection<OsmPrimitive> selectionList, boolean shift, boolean ctrl, boolean released) {
     439        if ((shift && ctrl) || (ctrl && !released))
    440440            return; // not allowed together
    441441
     
    447447
    448448        for (OsmPrimitive osm : selectionList)
     449        {
    449450            if (ctrl)
    450                 curSel.remove(osm);
     451            {
     452                if(curSel.contains(osm))
     453                    curSel.remove(osm);
     454                else
     455                    curSel.add(osm);
     456            }
    451457            else
    452458                curSel.add(osm);
     459        }
    453460        Main.ds.setSelected(curSel);
    454461        Main.map.mapView.repaint();
     
    463470            return tr("Release the mouse button to stop rotating.");
    464471        } else {
    465             return tr("Move objects by dragging; Shift to add to selection (Ctrl to remove); Shift-Ctrl to rotate selected; or change selection");
     472            return tr("Move objects by dragging; Shift to add to selection (Ctrl to toggle); Shift-Ctrl to rotate selected; or change selection");
    466473        }
    467474    }
Note: See TracChangeset for help on using the changeset viewer.