Ignore:
Timestamp:
2016-08-12T21:08:00+02:00 (8 years ago)
Author:
simon04
Message:

see #13319 - Use InputMapUtils where applicable (VK_ESCAPE)

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/InputMapUtils.java

    r10790 r10791  
    105105         c.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "spacebar");
    106106    }
     107
     108    /**
     109     * Add an action activated with ESCAPE key on a component or its children.
     110     * @param c The Swing component
     111     * @param a action activated with ESCAPE key
     112     * @see JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
     113     * @since 10791
     114     */
     115    public static void addEscapeAction(JComponent c, Action a) {
     116         c.getActionMap().put("escape", a);
     117         c.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape");
     118    }
    107119}
  • trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportDialog.java

    r10720 r10791  
    99import java.awt.GridBagLayout;
    1010import java.awt.event.ActionEvent;
    11 import java.awt.event.KeyEvent;
    1211
    1312import javax.swing.AbstractAction;
     
    1615import javax.swing.JButton;
    1716import javax.swing.JCheckBox;
    18 import javax.swing.JComponent;
    1917import javax.swing.JDialog;
    2018import javax.swing.JLabel;
    2119import javax.swing.JPanel;
    22 import javax.swing.KeyStroke;
    2320import javax.swing.UIManager;
    2421
     
    2926import org.openstreetmap.josm.tools.GBC;
    3027import org.openstreetmap.josm.tools.ImageProvider;
     28import org.openstreetmap.josm.tools.InputMapUtils;
    3129
    3230/**
     
    7270        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    7371
    74         getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape");
    75         getRootPane().getActionMap().put("escape", new AbstractAction() {
     72        InputMapUtils.addEscapeAction(getRootPane(), new AbstractAction() {
    7673            @Override
    7774            public void actionPerformed(ActionEvent e) {
Note: See TracChangeset for help on using the changeset viewer.