public class KeyHandler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private CommandQueue |
commandQueue
The
CommandQueue to use. |
private java.io.Writer |
debugKeyboard
The
Writer for logging keyboard debug output. |
private KeyBindings |
keyBindings
The active
KeyBindings . |
private KeybindingsManager |
keybindingsManager
The
KeybindingsManager to use. |
private KeyHandlerListener |
keyHandlerListener
The
KeyHandlerListener to notify. |
private java.text.DateFormat |
simpleDateFormat
A formatter for timestamps.
|
private JXCWindowRenderer |
windowRenderer
The
JXCWindowRenderer to use. |
Constructor and Description |
---|
KeyHandler(java.io.Writer debugKeyboard,
KeybindingsManager keybindingsManager,
CommandQueue commandQueue,
JXCWindowRenderer windowRenderer,
KeyHandlerListener keyHandlerListener)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
private void |
debugKeyboardWrite(java.lang.CharSequence message)
Writes a message to the keyboard debug.
|
private void |
debugKeyboardWrite(java.lang.String type,
java.awt.event.KeyEvent keyEvent,
KeyEvent2 keyEvent2)
Writes a
KeyEvent to the keyboard debug. |
private void |
handleKeyPress(KeyEvent2 e)
Handles a "key pressed" event.
|
private void |
handleKeyRelease(KeyEvent2 e)
Handles a "key released" event.
|
void |
keyPressed(java.awt.event.KeyEvent e)
Handles a "key pressed" event.
|
void |
keyReleased(java.awt.event.KeyEvent e)
Handles a "key released" event.
|
void |
setKeyBindings(KeyBindings keyBindings)
Sets the active
KeyBindings . |
private void |
updateModifiers(KeyEvent2 keyEvent)
Updates the saved modifier state from a key event.
|
@NotNull private final CommandQueue commandQueue
CommandQueue
to use.@Nullable private final java.io.Writer debugKeyboard
Writer
for logging keyboard debug output. Log nothing if
null
.@Nullable private KeyBindings keyBindings
KeyBindings
. Set to null
when no key bindings
are active.@NotNull private final KeybindingsManager keybindingsManager
KeybindingsManager
to use.@NotNull private final KeyHandlerListener keyHandlerListener
KeyHandlerListener
to notify.@NotNull private final java.text.DateFormat simpleDateFormat
@NotNull private final JXCWindowRenderer windowRenderer
JXCWindowRenderer
to use.public KeyHandler(@Nullable java.io.Writer debugKeyboard, @NotNull KeybindingsManager keybindingsManager, @NotNull CommandQueue commandQueue, @NotNull JXCWindowRenderer windowRenderer, @NotNull KeyHandlerListener keyHandlerListener)
debugKeyboard
- the writer for logging keyboard debug output; maykeybindingsManager
- the keybindings manager to usecommandQueue
- the command queue to usewindowRenderer
- the window renderer to usekeyHandlerListener
- the key handler listener to notifyprivate void debugKeyboardWrite(@NotNull java.lang.CharSequence message)
message
- the message to writeprivate void debugKeyboardWrite(@NotNull java.lang.String type, @NotNull java.awt.event.KeyEvent keyEvent, @NotNull KeyEvent2 keyEvent2)
KeyEvent
to the keyboard debug.type
- the event typekeyEvent
- the key event to writekeyEvent2
- the key event to writeprivate void handleKeyPress(@NotNull KeyEvent2 e)
e
- the key event to handleprivate void handleKeyRelease(@NotNull KeyEvent2 e)
e
- the key event to handlepublic void keyPressed(@NotNull java.awt.event.KeyEvent e)
e
- the key event to handlepublic void keyReleased(@NotNull java.awt.event.KeyEvent e)
e
- the key event to handlepublic void setKeyBindings(@NotNull KeyBindings keyBindings)
KeyBindings
.keyBindings
- the key bindings or null
to unsetprivate void updateModifiers(@NotNull KeyEvent2 keyEvent)
keyEvent
- the key event to process