Changeset 5052 in josm


Ignore:
Timestamp:
2012-03-08T10:25:23+01:00 (8 years ago)
Author:
xeen
Message:

fix #5170

File:
1 edited

Legend:

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

    r4982 r5052  
    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;
     
    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;
     
    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        }
Note: See TracChangeset for help on using the changeset viewer.