Changeset 17235 in josm
- Timestamp:
- 2020-10-18T13:24:50+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/widgets/DisableShortcutsOnFocusGainedTextField.java
r12643 r17235 3 3 4 4 import java.awt.event.FocusEvent; 5 import java.awt.event.InputEvent; 5 6 import java.awt.event.KeyEvent; 6 7 import java.util.ArrayList; … … 143 144 protected void unregisterActionShortcuts() { 144 145 unregisteredActionShortcuts.clear(); 145 // Unregister all actions with out modifiers to avoid them to be triggered by typing in this text field146 // Unregister all actions with Shift modifier or without modifiers to avoid them to be triggered by typing in this text field 146 147 for (Shortcut shortcut : Shortcut.listAll()) { 147 148 KeyStroke ks = shortcut.getKeyStroke(); … … 157 158 158 159 /** 159 * Returns true if the given shortcut has no modifier and is not an actions key.160 * Returns true if the given shortcut has Shift modifier or no modifier and is not an actions key. 160 161 * @param ks key stroke 161 162 * @return {@code true} if the given shortcut has to be disabled … … 163 164 */ 164 165 protected boolean hasToBeDisabled(KeyStroke ks) { 165 return ks != null && ks.getModifiers() == 0&& !new KeyEvent(166 return ks != null && (ks.getModifiers() == 0 || isOnlyShift(ks.getModifiers())) && !new KeyEvent( 166 167 this, KeyEvent.KEY_PRESSED, 0, ks.getModifiers(), ks.getKeyCode(), ks.getKeyChar()).isActionKey(); 168 } 169 170 private static boolean isOnlyShift(int modifiers) { 171 return (modifiers & InputEvent.SHIFT_DOWN_MASK) != 0 172 && (modifiers & InputEvent.CTRL_DOWN_MASK) == 0 173 && (modifiers & InputEvent.ALT_DOWN_MASK) == 0 174 && (modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) == 0 175 && (modifiers & InputEvent.META_DOWN_MASK) == 0; 167 176 } 168 177
Note:
See TracChangeset
for help on using the changeset viewer.