Ticket #25015: HouseNumberTaggingTool_dialog_position_focus.patch

File HouseNumberTaggingTool_dialog_position_focus.patch, 2.3 KB (added by Till_btn, 24 hours ago)
  • HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/LaunchAction.java

    diff --git a/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/LaunchAction.java b/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/LaunchAction.java
    index 400aa9ffe..44b091941 100644
    a b import java.awt.event.KeyEvent;  
    88import java.io.File;
    99import java.util.Set;
    1010
     11import javax.swing.JFrame;
     12
    1113import org.openstreetmap.josm.actions.JosmAction;
    1214import org.openstreetmap.josm.data.osm.DataSelectionListener;
    1315import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1416import org.openstreetmap.josm.data.osm.event.SelectionEventManager;
     17import org.openstreetmap.josm.gui.MainApplication;
    1518import org.openstreetmap.josm.tools.Shortcut;
    1619
    1720/**
    … … public class LaunchAction extends JosmAction implements DataSelectionListener {  
    6669     
    6770        TagDialog dialog = new TagDialog(pluginDir, selection, switchIncrement);
    6871        dialog.showDialog();
     72
     73        // give the focus back to JOSM
     74        JFrame mainFrame = MainApplication.getMainFrame();
     75        if (mainFrame != null) {
     76            mainFrame.toFront();
     77            mainFrame.requestFocus();
     78        }
     79        if (MainApplication.isDisplayingMapView()) {
     80            MainApplication.getMap().mapView.requestFocusInWindow();
     81        }
    6982    }
    7083
    7184    @Override
  • HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java

    diff --git a/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java b/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java
    index 917a44c58..379432c55 100644
    a b public class TagDialog extends ExtendedDialog {  
    147147        setupDialog();
    148148        getRootPane().setDefaultButton(defaultButton);
    149149
    150         // middle of the screen
    151         setLocationRelativeTo(null);
     150        // center on the JOSM main window
     151        setLocationRelativeTo(MainApplication.getMainFrame());
    152152
    153153        SwingUtilities.invokeLater(() -> {
    154154            housenumber.requestFocus();