keyboard: ESC while dragging mouse will cancel the current op
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@776 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
40bfdc241a
commit
c5872a6e9f
1 changed files with 20 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Reference in a new issue