Changeset 15053 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2019-05-05T21:04:04+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #17682 - run AddNodeAction later in EDT to make sure the KeyEvent triggering it is consumed before the dialog is shown

File:
1 edited

Legend:

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

    r14397 r15053  
    88import java.awt.event.KeyEvent;
    99import java.util.Collections;
     10
     11import javax.swing.SwingUtilities;
    1012
    1113import org.openstreetmap.josm.command.AddCommand;
     
    4345            return;
    4446
    45         LatLonDialog dialog = new LatLonDialog(MainApplication.getMainFrame(), tr("Add Node..."), ht("/Action/AddNode"));
     47        // #17682 - Run the action later in EDT to make sure the KeyEvent triggering it is consumed before the dialog is shown
     48        SwingUtilities.invokeLater(() -> {
     49            LatLonDialog dialog = new LatLonDialog(MainApplication.getMainFrame(), tr("Add Node..."), ht("/Action/AddNode"));
    4650
    47         if (textLatLon != null) {
    48             dialog.setLatLonText(textLatLon);
    49         }
    50         if (textEastNorth != null) {
    51             dialog.setEastNorthText(textEastNorth);
    52         }
     51            if (textLatLon != null) {
     52                dialog.setLatLonText(textLatLon);
     53            }
     54            if (textEastNorth != null) {
     55                dialog.setEastNorthText(textEastNorth);
     56            }
    5357
    54         dialog.showDialog();
     58            dialog.showDialog();
    5559
    56         if (dialog.getValue() != 1)
    57             return;
     60            if (dialog.getValue() != 1)
     61                return;
    5862
    59         LatLon coordinates = dialog.getCoordinates();
    60         if (coordinates == null)
    61             return;
     63            LatLon coordinates = dialog.getCoordinates();
     64            if (coordinates == null)
     65                return;
    6266
    63         textLatLon = dialog.getLatLonText();
    64         textEastNorth = dialog.getEastNorthText();
     67            textLatLon = dialog.getLatLonText();
     68            textEastNorth = dialog.getEastNorthText();
    6569
    66         Node nnew = new Node(coordinates);
     70            Node nnew = new Node(coordinates);
    6771
    68         // add the node
    69         DataSet ds = getLayerManager().getEditDataSet();
    70         UndoRedoHandler.getInstance().add(new AddCommand(ds, nnew));
    71         ds.setSelected(nnew);
    72         MapView mapView = MainApplication.getMap().mapView;
    73         if (mapView != null && !mapView.getRealBounds().contains(nnew.getCoor())) {
    74             AutoScaleAction.zoomTo(Collections.<OsmPrimitive>singleton(nnew));
    75         }
     72            // add the node
     73            DataSet ds = getLayerManager().getEditDataSet();
     74            UndoRedoHandler.getInstance().add(new AddCommand(ds, nnew));
     75            ds.setSelected(nnew);
     76            MapView mapView = MainApplication.getMap().mapView;
     77            if (mapView != null && !mapView.getRealBounds().contains(nnew.getCoor())) {
     78                AutoScaleAction.zoomTo(Collections.<OsmPrimitive>singleton(nnew));
     79            }
     80        });
    7681    }
    7782
Note: See TracChangeset for help on using the changeset viewer.