diff --git a/src/org/openstreetmap/josm/actions/DuplicateAction.java b/src/org/openstreetmap/josm/actions/DuplicateAction.java
index c297076..d26003e 100644
a
|
b
|
import java.awt.event.KeyEvent;
|
10 | 10 | import java.util.Collection; |
11 | 11 | |
12 | 12 | import org.openstreetmap.josm.Main; |
| 13 | import org.openstreetmap.josm.data.coor.EastNorth; |
13 | 14 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
14 | 15 | import org.openstreetmap.josm.gui.datatransfer.OsmTransferHandler; |
15 | 16 | import org.openstreetmap.josm.gui.datatransfer.PrimitiveTransferable; |
… |
… |
public final class DuplicateAction extends JosmAction {
|
34 | 35 | @Override |
35 | 36 | public void actionPerformed(ActionEvent e) { |
36 | 37 | PrimitiveTransferData data = PrimitiveTransferData.getDataWithReferences(getLayerManager().getEditDataSet().getSelected()); |
37 | | new OsmTransferHandler().pasteOn(Main.getLayerManager().getEditLayer(), data.getCenter(), new PrimitiveTransferable(data)); |
| 38 | EastNorth mPosition = PasteAction.computePastePosition(e, getValue(NAME)); |
| 39 | new OsmTransferHandler().pasteOn(Main.getLayerManager().getEditLayer(), mPosition, new PrimitiveTransferable(data)); |
38 | 40 | } |
39 | 41 | |
40 | 42 | @Override |
diff --git a/src/org/openstreetmap/josm/actions/PasteAction.java b/src/org/openstreetmap/josm/actions/PasteAction.java
index 19f076b..a81bc0a 100644
a
|
b
|
public final class PasteAction extends JosmAction implements FlavorListener {
|
42 | 42 | |
43 | 43 | @Override |
44 | 44 | public void actionPerformed(ActionEvent e) { |
| 45 | EastNorth mPosition = computePastePosition(e, getValue(NAME)); |
| 46 | |
| 47 | transferHandler.pasteOn(Main.getLayerManager().getEditLayer(), mPosition); |
| 48 | } |
| 49 | |
| 50 | static EastNorth computePastePosition(ActionEvent e, Object name) { |
45 | 51 | // default to paste in center of map (pasted via menu or cursor not in MapView) |
46 | 52 | EastNorth mPosition = Main.map.mapView.getCenter(); |
47 | 53 | // We previously checked for modifier to know if the action has been trigerred via shortcut or via menu |
48 | 54 | // But this does not work if the shortcut is changed to a single key (see #9055) |
49 | 55 | // 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())) { |
| 56 | if (e != null && !name.equals(e.getActionCommand())) { |
51 | 57 | final Point mp = MouseInfo.getPointerInfo().getLocation(); |
52 | 58 | final Point tl = Main.map.mapView.getLocationOnScreen(); |
53 | 59 | final Point pos = new Point(mp.x-tl.x, mp.y-tl.y); |
… |
… |
public final class PasteAction extends JosmAction implements FlavorListener {
|
55 | 61 | mPosition = Main.map.mapView.getEastNorth(pos.x, pos.y); |
56 | 62 | } |
57 | 63 | } |
58 | | |
59 | | transferHandler.pasteOn(Main.getLayerManager().getEditLayer(), mPosition); |
| 64 | return mPosition; |
60 | 65 | } |
61 | 66 | |
62 | 67 | @Override |