Changeset 10682 in josm


Ignore:
Timestamp:
2016-07-31T12:28:39+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13203 - Ctrl-D (Duplicate) places new object on top of source object (patch by michael2402) - gsoc-core

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

Legend:

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

    r10606 r10682  
    3535    public void actionPerformed(ActionEvent e) {
    3636        PrimitiveTransferData data = PrimitiveTransferData.getDataWithReferences(getLayerManager().getEditDataSet().getSelected());
    37         new OsmTransferHandler().pasteOn(Main.getLayerManager().getEditLayer(), data.getCenter(), new PrimitiveTransferable(data));
     37        new OsmTransferHandler().pasteOn(Main.getLayerManager().getEditLayer(),
     38                PasteAction.computePastePosition(e, getValue(NAME)), new PrimitiveTransferable(data));
    3839    }
    3940
  • trunk/src/org/openstreetmap/josm/actions/PasteAction.java

    r10604 r10682  
    4343    @Override
    4444    public void actionPerformed(ActionEvent e) {
     45        transferHandler.pasteOn(Main.getLayerManager().getEditLayer(), computePastePosition(e, getValue(NAME)));
     46    }
     47
     48    static EastNorth computePastePosition(ActionEvent e, Object name) {
    4549        // default to paste in center of map (pasted via menu or cursor not in MapView)
    4650        EastNorth mPosition = Main.map.mapView.getCenter();
     
    4852        // But this does not work if the shortcut is changed to a single key (see #9055)
    4953        // Observed behaviour: getActionCommand() returns Action.NAME when triggered via menu, but shortcut text when triggered with it
    50         if (e != null && !getValue(NAME).equals(e.getActionCommand())) {
     54        if (e != null && !name.equals(e.getActionCommand())) {
    5155            final Point mp = MouseInfo.getPointerInfo().getLocation();
    5256            final Point tl = Main.map.mapView.getLocationOnScreen();
     
    5660            }
    5761        }
    58 
    59         transferHandler.pasteOn(Main.getLayerManager().getEditLayer(), mPosition);
     62        return mPosition;
    6063    }
    6164
Note: See TracChangeset for help on using the changeset viewer.