Changeset 3030 in josm


Ignore:
Timestamp:
2010-02-21T09:34:24+01:00 (15 years ago)
Author:
bastiK
Message:

fixed #4583 - "Download object" ignores Enter

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r2923 r3030  
    1313import javax.swing.JLabel;
    1414import javax.swing.JPanel;
     15import javax.swing.KeyStroke;
    1516
    1617import org.openstreetmap.josm.Main;
     
    6263        OsmIdTextField tfId = new OsmIdTextField();
    6364        tfId.setToolTipText(tr("Enter the ID of the object that should be downloaded"));
     65        // forward the enter key stroke to the download button
     66        tfId.getKeymap().removeKeyStrokeBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false));
    6467        gc.weightx = 1;
    6568        all.add(tfId, gc);
     
    8184                tr("Close dialog and cancel downloading")
    8285        });
     86        dialog.setDefaultButton(1);
    8387        dialog.configureContextsensitiveHelp("/Action/DownloadObject", true /* show help button */);
    8488        dialog.showDialog();
  • trunk/src/org/openstreetmap/josm/gui/widgets/AbstractTextComponentValidator.java

    r2801 r3030  
    8484     */
    8585    public AbstractTextComponentValidator(JTextComponent tc) throws IllegalArgumentException {
     86        this(tc, true);
     87    }
     88
     89    /**
     90     * Alternative constructor that allows to turn off the actionListener.
     91     * This can be useful if the enter key stroke needs to be forwarded to the default button in a dialog.
     92     */
     93    public AbstractTextComponentValidator(JTextComponent tc, boolean addActionListener) throws IllegalArgumentException {
    8694        CheckParameterUtil.ensureParameterNotNull(tc, "tc");
    8795        this.tc = tc;
    8896        tc.addFocusListener(this);
    8997        tc.getDocument().addDocumentListener(this);
    90         if (tc instanceof JTextField) {
    91             JTextField tf = (JTextField)tc;
    92             tf.addActionListener(this);
     98        if (addActionListener) {
     99            if (tc instanceof JTextField) {
     100                JTextField tf = (JTextField)tc;
     101                tf.addActionListener(this);
     102            }
    93103        }
    94104        tc.addPropertyChangeListener("enabled", this);
  • trunk/src/org/openstreetmap/josm/gui/widgets/OsmIdTextField.java

    r2923 r3030  
    3333
    3434        public OsmIdValidator(JTextComponent tc) {
    35             super(tc);
     35            super(tc, false);
    3636        }
    3737
Note: See TracChangeset for help on using the changeset viewer.