diff --git a/src/org/openstreetmap/josm/gui/bbox/SlippyMapController.java b/src/org/openstreetmap/josm/gui/bbox/SlippyMapController.java
index 10e50cc1fd..0254109965 100644
|
a
|
b
|
|
| 1 | 1 | // License: GPL. For details, see LICENSE file. |
| 2 | 2 | package org.openstreetmap.josm.gui.bbox; |
| 3 | 3 | |
| | 4 | import java.awt.KeyboardFocusManager; |
| 4 | 5 | import java.awt.Point; |
| 5 | 6 | import java.awt.event.ActionEvent; |
| 6 | 7 | import java.awt.event.InputEvent; |
| … |
… |
import javax.swing.InputMap;
|
| 16 | 17 | import javax.swing.JComponent; |
| 17 | 18 | import javax.swing.JPanel; |
| 18 | 19 | import javax.swing.KeyStroke; |
| | 20 | import javax.swing.text.JTextComponent; |
| 19 | 21 | |
| 20 | 22 | import org.openstreetmap.josm.tools.PlatformManager; |
| 21 | 23 | |
| … |
… |
public class SlippyMapController extends MouseAdapter {
|
| 92 | 94 | |
| 93 | 95 | // zooming. To avoid confusion about which modifier key to use, |
| 94 | 96 | // we just add all keys left of the space bar |
| | 97 | // |
| | 98 | // Typing the '+', '=', or '-' character in the Overpass query field |
| | 99 | // seems to trigger these key bindings, which would zoom the map |
| | 100 | // (https://josm.openstreetmap.de/ticket/24392). To prevent that, those |
| | 101 | // keys use a special version of the action that does nothing if a text |
| | 102 | // field is focused. That feels like a hack, but we didn't find an |
| | 103 | // obvious better way. |
| 95 | 104 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK, false), "ZOOM_IN"); |
| 96 | 105 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.META_DOWN_MASK, false), "ZOOM_IN"); |
| 97 | 106 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_DOWN_MASK, false), "ZOOM_IN"); |
| 98 | | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0, false), "ZOOM_IN"); |
| 99 | | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0, false), "ZOOM_IN"); |
| 100 | | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, 0, false), "ZOOM_IN"); |
| 101 | | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.SHIFT_DOWN_MASK, false), "ZOOM_IN"); |
| | 107 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0, false), "ZOOM_IN_UNLESS_TYPING"); |
| | 108 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0, false), "ZOOM_IN_UNLESS_TYPING"); |
| | 109 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, 0, false), "ZOOM_IN_UNLESS_TYPING"); |
| | 110 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.SHIFT_DOWN_MASK, false), "ZOOM_IN_UNLESS_TYPING"); |
| 102 | 111 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK, false), "ZOOM_OUT"); |
| 103 | 112 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.META_DOWN_MASK, false), "ZOOM_OUT"); |
| 104 | 113 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_DOWN_MASK, false), "ZOOM_OUT"); |
| 105 | | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, 0, false), "ZOOM_OUT"); |
| 106 | | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0, false), "ZOOM_OUT"); |
| | 114 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, 0, false), "ZOOM_OUT_UNLESS_TYPING"); |
| | 115 | inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0, false), "ZOOM_OUT_UNLESS_TYPING"); |
| 107 | 116 | |
| 108 | 117 | // action mapping |
| 109 | 118 | actionMap.put("MOVE_RIGHT", new MoveXAction(1)); |
| … |
… |
public class SlippyMapController extends MouseAdapter {
|
| 112 | 121 | actionMap.put("MOVE_DOWN", new MoveYAction(1)); |
| 113 | 122 | actionMap.put("STOP_MOVE_HORIZONTALLY", new MoveXAction(0)); |
| 114 | 123 | actionMap.put("STOP_MOVE_VERTICALLY", new MoveYAction(0)); |
| 115 | | actionMap.put("ZOOM_IN", new ZoomInAction()); |
| 116 | | actionMap.put("ZOOM_OUT", new ZoomOutAction()); |
| | 124 | actionMap.put("ZOOM_IN", new ZoomInAction(false)); |
| | 125 | actionMap.put("ZOOM_IN_UNLESS_TYPING", new ZoomInAction(true)); |
| | 126 | actionMap.put("ZOOM_OUT", new ZoomOutAction(false)); |
| | 127 | actionMap.put("ZOOM_OUT_UNLESS_TYPING", new ZoomOutAction(true)); |
| 117 | 128 | } |
| 118 | 129 | |
| 119 | 130 | /** |
| … |
… |
public class SlippyMapController extends MouseAdapter {
|
| 300 | 311 | } |
| 301 | 312 | } |
| 302 | 313 | |
| | 314 | static boolean isTyping() { |
| | 315 | return KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() instanceof JTextComponent; |
| | 316 | } |
| | 317 | |
| 303 | 318 | private final class ZoomInAction extends AbstractAction { |
| 304 | 319 | |
| | 320 | private boolean suppressWhileTyping; |
| | 321 | |
| | 322 | ZoomInAction(boolean suppressWhileTyping) { |
| | 323 | this.suppressWhileTyping = suppressWhileTyping; |
| | 324 | } |
| | 325 | |
| 305 | 326 | @Override |
| 306 | 327 | public void actionPerformed(ActionEvent e) { |
| | 328 | if (suppressWhileTyping && isTyping()) |
| | 329 | return; |
| 307 | 330 | iSlippyMapChooser.zoomIn(); |
| 308 | 331 | } |
| 309 | 332 | } |
| 310 | 333 | |
| 311 | 334 | private final class ZoomOutAction extends AbstractAction { |
| 312 | 335 | |
| | 336 | private boolean suppressWhileTyping; |
| | 337 | |
| | 338 | ZoomOutAction(boolean suppressWhileTyping) { |
| | 339 | this.suppressWhileTyping = suppressWhileTyping; |
| | 340 | } |
| | 341 | |
| 313 | 342 | @Override |
| 314 | 343 | public void actionPerformed(ActionEvent e) { |
| | 344 | if (suppressWhileTyping && isTyping()) |
| | 345 | return; |
| 315 | 346 | iSlippyMapChooser.zoomOut(); |
| 316 | 347 | } |
| 317 | 348 | } |