Ticket #6764: dilemma_fix.patch

File dilemma_fix.patch, 3.7 KB (added by xeen, 13 years ago)
  • src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

     
    273273    private boolean giveUserFeedback(MouseEvent e, int modifiers) {
    274274        boolean needsRepaint = false;
    275275
     276        // the target highlight will always be wrong, regardless if already selected values
     277        // are preferred or not. The reason for this is that in when moving primitives they
     278        // need to, otherwise it's hard to move the selection (#6334). However, when in select
     279        // mode this makes it hard to select primitives close to each other (#6764). Deciding
     280        // if a move or selection occurs can only be done after the mouse button has been
     281        // released so it's impossible to always get the highlighting right. It's currently set
     282        // to highlight the other primitive, but use the selected on move.
    276283        Collection<OsmPrimitive> c = MapView.asColl(
    277                 mv.getNearestNodeOrWay(e.getPoint(), OsmPrimitive.isSelectablePredicate, true));
     284                mv.getNearestNodeOrWay(e.getPoint(), OsmPrimitive.isSelectablePredicate, false));
    278285
    279286        updateKeyModifiers(modifiers);
    280287        determineMapMode(!c.isEmpty());
     
    664671        mouseDownTime = System.currentTimeMillis();
    665672        lastMousePos = e.getPoint();
    666673
     674        // this is used for most actions but may be overwritten on mouse release in order
     675        // to cycle through close primitives. Note that already selected primitives need
     676        // to be preferred, otherwise it gets hard to move the selection (see #6334).
     677        // Compare to the large comment in giveUserFeedback if you change this.
    667678        Collection<OsmPrimitive> c = MapView.asColl(
    668679                mv.getNearestNodeOrWay(e.getPoint(), OsmPrimitive.isSelectablePredicate, true));
     680        System.out.println("--");
     681        System.out.println(mv.getNearestNodeOrWay(e.getPoint(), OsmPrimitive.isSelectablePredicate, false));
     682        System.out.println(mv.getNearestNodeOrWay(e.getPoint(), OsmPrimitive.isSelectablePredicate, true));
    669683
    670684        determineMapMode(!c.isEmpty());
    671685        switch(mode) {
     
    684698            if (!cancelDrawMode && c.iterator().next() instanceof Way) {
    685699                setupVirtual(e);
    686700            }
    687 
    688             selectPrims(cycleSetup(c, e), e, false, false);
     701            selectPrims(c, e, false, false);
    689702            break;
    690703        case select:
    691704        default:
     
    722735                virtualNode = null;
    723736
    724737                // do nothing if the click was to short too be recognized as a drag,
    725                 // but the release position is farther than 10px away from the press position
     738                // but the release position is farther than 10px away from the press position.
     739                // if it's within that radius, so some selection magic:
    726740                if (lastMousePos == null || lastMousePos.distanceSq(e.getPoint()) < 100) {
     741                    // do NOT prefer already selected primitives here. Otherwise it gets very hard to
     742                    // select primitives that are close to each other (see #6764). Compare to the large
     743                    // comment in giveUserFeedback if you change this.
     744                    Collection<OsmPrimitive> single = MapView.asColl(
     745                            mv.getNearestNodeOrWay(e.getPoint(), OsmPrimitive.isSelectablePredicate, false));
     746                    cycleSetup(single, e);
    727747                    selectPrims(cyclePrims(cycleList, e), e, true, false);
    728748
    729749                    // If the user double-clicked a node, change to draw mode