Changeset 7609 in josm
- Timestamp:
- 2014-10-11T17:27:50+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/util/AdvancedKeyPressDetector.java
r7539 r7609 125 125 } else if (set.add((e.getKeyCode())) && enabled) { 126 126 synchronized (this) { 127 for (KeyPressReleaseListener q: keyListeners) { 128 q.doKeyPressed(e); 127 if (isFocusInMainWindow()) { 128 for (KeyPressReleaseListener q: keyListeners) { 129 q.doKeyPressed(e); 130 } 129 131 } 130 132 } … … 135 137 if (set.remove(e.getKeyCode()) && enabled) { 136 138 synchronized (this) { 137 for (KeyPressReleaseListener q: keyListeners) { 138 q.doKeyReleased(e); 139 if (isFocusInMainWindow()) { 140 for (KeyPressReleaseListener q: keyListeners) { 141 q.doKeyReleased(e); 142 } 139 143 } 140 144 } … … 165 169 } 166 170 167 // check if key press is done in main window, not in dialogs 168 Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); 169 if (SwingUtilities.getWindowAncestor(focused) instanceof JFrame) { 170 processKeyEvent(ke); 171 } 171 processKeyEvent(ke); 172 172 } 173 173 … … 190 190 this.enabled = enabled; 191 191 } 192 193 private boolean isFocusInMainWindow() { 194 Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); 195 return SwingUtilities.getWindowAncestor(focused) instanceof JFrame; 196 } 192 197 }
Note:
See TracChangeset
for help on using the changeset viewer.