Changeset 12531 in josm


Ignore:
Timestamp:
2017-07-29T07:26:50+02:00 (7 years ago)
Author:
simon04
Message:

fix #15089 - UploadDialog: bind Ctrl+Enter to upload action

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r12452 r12531  
    1212import java.awt.GridBagLayout;
    1313import java.awt.event.ActionEvent;
     14import java.awt.event.InputEvent;
     15import java.awt.event.KeyEvent;
    1416import java.awt.event.WindowAdapter;
    1517import java.awt.event.WindowEvent;
     
    2931
    3032import javax.swing.AbstractAction;
     33import javax.swing.Action;
    3134import javax.swing.BorderFactory;
    3235import javax.swing.Icon;
    3336import javax.swing.JButton;
     37import javax.swing.JComponent;
    3438import javax.swing.JOptionPane;
    3539import javax.swing.JPanel;
    3640import javax.swing.JTabbedPane;
     41import javax.swing.KeyStroke;
    3742
    3843import org.openstreetmap.josm.Main;
     
    178183        btnUpload.setFocusable(true);
    179184        InputMapUtils.enableEnter(btnUpload);
     185        bindCtrlEnterToAction(getRootPane(), btnUpload.getAction());
    180186
    181187        // -- cancel button
     
    476482            }
    477483
    478             ExtendedDialog dlg = new ExtendedDialog((Component) dialog, title, buttonTexts);
     484            ExtendedDialog dlg = new ExtendedDialog((Component) dialog, title, buttonTexts) {
     485                @Override
     486                public void setupDialog() {
     487                    super.setupDialog();
     488                    bindCtrlEnterToAction(getRootPane(), buttons.get(buttons.size() - 1).getAction());
     489                }
     490            };
    479491            dlg.setContent("<html>" + message + "</html>");
    480492            dlg.setButtonIcons(buttonIcons);
     
    685697        tpConfigPanels.setSelectedIndex(0);
    686698    }
     699
     700    private static void bindCtrlEnterToAction(JComponent component, Action actionToBind) {
     701        final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK);
     702        component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "ctrl_enter");
     703        component.getActionMap().put("ctrl_enter", actionToBind);
     704    }
    687705}
Note: See TracChangeset for help on using the changeset viewer.