Changeset 8210 in josm for trunk


Ignore:
Timestamp:
2015-04-18T01:35:39+02:00 (10 years ago)
Author:
simon04
Message:

fix #11326 - Cancel note creation with escape key, do not create note with right click

File:
1 edited

Legend:

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

    r8056 r8210  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.event.KeyEvent;
    67import java.awt.event.MouseEvent;
    78
    89import javax.swing.JOptionPane;
     10import javax.swing.SwingUtilities;
    911
    1012import org.openstreetmap.josm.Main;
     
    1517import org.openstreetmap.josm.gui.Notification;
    1618import org.openstreetmap.josm.gui.dialogs.NotesDialog;
     19import org.openstreetmap.josm.gui.util.KeyPressReleaseListener;
    1720import org.openstreetmap.josm.tools.CheckParameterUtil;
    1821import org.openstreetmap.josm.tools.ImageProvider;
     
    2225 * prompts the user for text and adds a note to the note layer
    2326 */
    24 public class AddNoteAction extends MapMode {
     27public class AddNoteAction extends MapMode implements KeyPressReleaseListener {
    2528
    2629    private NoteData noteData;
     
    4851        super.enterMode();
    4952        Main.map.mapView.addMouseListener(this);
     53        Main.map.keyDetector.addKeyListener(this);
    5054    }
    5155
     
    5458        super.exitMode();
    5559        Main.map.mapView.removeMouseListener(this);
     60        Main.map.keyDetector.removeKeyListener(this);
    5661    }
    5762
    5863    @Override
    5964    public void mouseClicked(MouseEvent e) {
     65        if (!SwingUtilities.isLeftMouseButton(e)) {
     66            // allow to pan without distraction
     67            return;
     68        }
    6069        Main.map.selectMapMode(Main.map.mapModeSelect);
    6170        LatLon latlon = Main.map.mapView.getLatLon(e.getPoint().x, e.getPoint().y);
     
    7786        }
    7887    }
     88
     89    @Override
     90    public void doKeyPressed(KeyEvent e) {
     91        if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
     92            Main.map.selectMapMode(Main.map.mapModeSelect);
     93        }
     94    }
     95
     96    @Override
     97    public void doKeyReleased(KeyEvent e) {
     98    }
    7999}
Note: See TracChangeset for help on using the changeset viewer.