Ignore:
Timestamp:
2009-10-29T19:45:49+01:00 (14 years ago)
Author:
Gubaer
Message:

applied #3780: patch by hansendc: Shift selection is broken

File:
1 edited

Legend:

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

    r2310 r2348  
    499499                    }
    500500                }
    501                 DataSet.fireSelectionChanged(selection);
     501                getCurrentDataSet().fireSelectionChanged();
    502502            }
    503503        }
     
    515515    public void selectPrims(Collection<OsmPrimitive> selectionList, boolean shift,
    516516            boolean ctrl, boolean released, boolean area) {
     517        DataSet ds = getCurrentDataSet();
    517518        if ((shift && ctrl) || (ctrl && !released))
    518519            return; // not allowed together
    519520
    520         Collection<OsmPrimitive> curSel;
    521         if (!ctrl && !shift) {
    522             curSel = new LinkedList<OsmPrimitive>(); // new selection will replace the old.
     521        // plain clicks with no modifiers clear the selection
     522        if (!ctrl && !shift)
     523            ds.clearSelection();
     524
     525        if (ctrl) {
     526            // Ctrl on an item toggles its selection status,
     527            // but Ctrl on an *area* just clears those items
     528            // out of the selection.
     529            if (area)
     530                ds.clearSelection(selectionList);
     531            else
     532                ds.toggleSelected(selectionList);
    523533        } else {
    524             curSel = getCurrentDataSet().getSelected();
    525         }
    526 
    527         for (OsmPrimitive osm : selectionList)
    528         {
    529             if (ctrl)
    530             {
    531                 if(curSel.contains(osm)) {
    532                     curSel.remove(osm);
    533                 } else if(!area) {
    534                     curSel.add(osm);
    535                 }
    536             } else {
    537                 curSel.add(osm);
    538             }
    539         }
    540         getCurrentDataSet().setSelected(curSel);
     534            // This is either a plain click (which means we
     535            // previously cleared the selection), or a
     536            // shift-click where we are adding things to an
     537            // existing selection.
     538            ds.addSelected(selectionList);
     539        }
     540        ds.fireSelectionChanged();
    541541        Main.map.mapView.repaint();
    542542    }
Note: See TracChangeset for help on using the changeset viewer.