From 060fdc4b94e94bd042b9648da1053f8fdb1fc418 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Sun, 21 Jul 2013 15:35:01 +0000 Subject: [PATCH] drawing-area: fix so that keyboard zoom works even when a button has focus git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@767 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/gui/MainWindow.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/micropolisj/gui/MainWindow.java b/src/micropolisj/gui/MainWindow.java index 4585af3..2c91e40 100644 --- a/src/micropolisj/gui/MainWindow.java +++ b/src/micropolisj/gui/MainWindow.java @@ -182,9 +182,10 @@ public class MainWindow extends JFrame setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); setLocationRelativeTo(null); - getRootPane().getInputMap().put(KeyStroke.getKeyStroke("ADD"), "zoomIn"); - getRootPane().getInputMap().put(KeyStroke.getKeyStroke("shift EQUALS"), "zoomIn"); - getRootPane().getInputMap().put(KeyStroke.getKeyStroke("MINUS"), "zoomOut"); + InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + inputMap.put(KeyStroke.getKeyStroke("ADD"), "zoomIn"); + inputMap.put(KeyStroke.getKeyStroke("shift EQUALS"), "zoomIn"); + inputMap.put(KeyStroke.getKeyStroke("MINUS"), "zoomOut"); getRootPane().getActionMap().put("zoomIn", new AbstractAction() { public void actionPerformed(ActionEvent evt) {