Ticket #5170: fix5170.patch

File fix5170.patch, 2.3 KB (added by xeen, 14 years ago)

I’ll commit after stabilization because the new behaviour might be confusing for people.

  • src/org/openstreetmap/josm/actions/PasteAction.java

     
    55import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    66import static org.openstreetmap.josm.tools.I18n.tr;
    77
     8import java.awt.MouseInfo;
     9import java.awt.Point;
    810import java.awt.event.ActionEvent;
    911import java.awt.event.KeyEvent;
    1012import java.util.ArrayList;
     
    1921import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    2022import org.openstreetmap.josm.data.osm.PrimitiveData;
    2123import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy;
    22 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy.PasteBufferChangedListener;
    2324import org.openstreetmap.josm.data.osm.RelationData;
    2425import org.openstreetmap.josm.data.osm.RelationMemberData;
    2526import org.openstreetmap.josm.data.osm.WayData;
     27import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy.PasteBufferChangedListener;
    2628import org.openstreetmap.josm.gui.ExtendedDialog;
    2729import org.openstreetmap.josm.gui.layer.Layer;
    2830import org.openstreetmap.josm.tools.Shortcut;
     
    6668            if (!confirmDeleteIncomplete()) return;
    6769        }
    6870
    69         EastNorth mPosition;
    70         if((e.getModifiers() & ActionEvent.CTRL_MASK) ==0){
    71             /* adjust the coordinates to the middle of the visible map area */
    72             mPosition = Main.map.mapView.getCenter();
    73         } else {
    74             if (Main.map.mapView.lastMEvent != null) {
    75                 mPosition = Main.map.mapView.getEastNorth(Main.map.mapView.lastMEvent.getX(), Main.map.mapView.lastMEvent.getY());
    76             } else {
    77                 mPosition = Main.map.mapView.getCenter();
     71        // default to paste in center of map (pasted via menu or cursor not in MapView)
     72        EastNorth mPosition = Main.map.mapView.getCenter();
     73        if((e.getModifiers() & ActionEvent.CTRL_MASK) != 0) {
     74            final Point mp = MouseInfo.getPointerInfo().getLocation();
     75            final Point tl = Main.map.mapView.getLocationOnScreen();
     76            final Point pos = new Point(mp.x-tl.x, mp.y-tl.y);
     77            if(Main.map.mapView.contains(pos)) {
     78                mPosition = Main.map.mapView.getEastNorth(pos.x, pos.y);
    7879            }
    7980        }
    8081