Package org.openstreetmap.josm.gui.util
Class AdvancedKeyPressDetector
java.lang.Object
org.openstreetmap.josm.gui.util.AdvancedKeyPressDetector
- All Implemented Interfaces:
AWTEventListener,EventListener
Helper object that allows cross-platform detection of key press and release events
instance is available globally as
Main.map.keyDetector.- Since:
- 7217
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final List<KeyPressReleaseListener>private final ListenerList<ModifierExListener>private intprivate KeyEventprivate Timer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an object that wants to receive key press and release events.voidAdds an object that wants to receive extended key modifier changed events.voidprivate static booleanbooleanisKeyPressed(int keyCode) Allows to determine if the key with specific code is pressed nowprivate voidvoidregister()Register this object as AWTEventListenervoidRemoves the listener.voidRemoves the extended key modifier listener.final voidsetEnabled(boolean enabled) Sets the enabled state of the key detector.voidUnregister this object as AWTEventListener lists of listeners are not cleared!
-
Field Details
-
set
-
releaseEvent
-
timer
-
keyListeners
-
modifierExListeners
-
previousModifiersEx
-
enabled
-
-
Constructor Details
-
AdvancedKeyPressDetector
public AdvancedKeyPressDetector()
-
-
Method Details
-
addKeyListener
Adds an object that wants to receive key press and release events.- Parameters:
l- listener to add
-
addModifierExListener
Adds an object that wants to receive extended key modifier changed events.- Parameters:
l- listener to add- Since:
- 12517
-
removeKeyListener
Removes the listener.- Parameters:
l- listener to remove
-
removeModifierExListener
Removes the extended key modifier listener.- Parameters:
l- listener to remove- Since:
- 12517
-
register
Register this object as AWTEventListener -
unregister
Unregister this object as AWTEventListener lists of listeners are not cleared! -
processKeyEvent
-
eventDispatched
- Specified by:
eventDispatchedin interfaceAWTEventListener
-
isKeyPressed
Allows to determine if the key with specific code is pressed now- Parameters:
keyCode- the key code, for example KeyEvent.VK_ENTER- Returns:
- true if the key is pressed now
-
setEnabled
Sets the enabled state of the key detector. We need to disable it when text fields that disable shortcuts gain focus.- Parameters:
enabled- iftrue, enables this key detector. Iffalse, disables it- Since:
- 7539
-
isFocusInMainWindow
-