diff --git a/src/micropolisj/gui/MainWindow.java b/src/micropolisj/gui/MainWindow.java index 90e1986..e3223c4 100644 --- a/src/micropolisj/gui/MainWindow.java +++ b/src/micropolisj/gui/MainWindow.java @@ -189,6 +189,7 @@ public class MainWindow extends JFrame inputMap.put(KeyStroke.getKeyStroke("shift EQUALS"), "zoomIn"); inputMap.put(KeyStroke.getKeyStroke("SUBTRACT"), "zoomOut"); inputMap.put(KeyStroke.getKeyStroke("MINUS"), "zoomOut"); + inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "escape"); getRootPane().getActionMap().put("zoomIn", new AbstractAction() { public void actionPerformed(ActionEvent evt) { @@ -200,6 +201,11 @@ public class MainWindow extends JFrame doZoom(-1); } }); + getRootPane().getActionMap().put("escape", new AbstractAction() { + public void actionPerformed(ActionEvent evt) { + onEscapePressed(); + } + }); MouseAdapter mouse = new MouseAdapter() { public void mousePressed(MouseEvent ev) @@ -1166,6 +1172,20 @@ public class MainWindow extends JFrame this.lastY = y; } + private void onEscapePressed() + { + // if currently dragging a tool... + if (toolStroke != null) { + // cancel the current mouse operation + toolStroke = null; + drawingArea.setToolPreview(null); + drawingArea.setToolCursor(null); + } + else { + // TODO dismiss any alerts currently visible + } + } + private void onToolUp(MouseEvent ev) { if (toolStroke != null) {