public abstract class SwingKeyboardReader
extends java.awt.event.KeyAdapter
KeyAdapter.keyTyped(java.awt.event.KeyEvent)
and all other
key codes are handled by keyPressed(java.awt.event.KeyEvent)
. keyReleased(java.awt.event.KeyEvent)
is not
used since Progress generates all key input on the key press instead of on
the key releasse.
All input that is not dropped is translated as needed and then is stored
in a FIFO queue which represents the key input buffer for the application.
This key input is read using read()
.
Known Issues and/or TODOs
Modifier and Type | Field and Description |
---|---|
protected java.util.Deque<java.awt.event.KeyEvent> |
keyDownEvents
The stack of keystrokes to parse, contains key down events.
|
protected java.util.concurrent.LinkedBlockingQueue<KeyCode> |
queue
Incoming keystroke buffer.
|
protected java.util.Map<java.lang.Integer,java.lang.Integer> |
xlate
Translation map of Java virtual keys to Progress key codes.
|
Constructor and Description |
---|
SwingKeyboardReader()
Default c'tor.
|
Modifier and Type | Method and Description |
---|---|
protected java.awt.event.KeyEvent |
findKeyEventByKeyCode(int keyCode)
Finds the first key down event that has the given key code.
|
void |
insert(java.lang.String data)
Add each character of the string to end of the key input buffer in FIFO
order (left to right).
|
static boolean |
isModifier(int key)
Tests if the given key code is a modifier.
|
static boolean |
isSpecialCharacter(java.awt.event.KeyEvent evt)
Tests if the pressed key is @, ^, _ , \, ]
|
void |
keyPressed(java.awt.event.KeyEvent evt)
Invoked when a key has been pressed.
|
void |
keyReleased(java.awt.event.KeyEvent evt)
Invoked when a key has been released.
|
static void |
mergeWithLastEvent(java.awt.event.KeyEvent last,
java.awt.event.KeyEvent evt)
Merges the java keyboard event with the last key event.
|
KeyCode |
read()
Read a keystroke from the key input buffer.
|
protected final java.util.Deque<java.awt.event.KeyEvent> keyDownEvents
protected final java.util.concurrent.LinkedBlockingQueue<KeyCode> queue
protected final java.util.Map<java.lang.Integer,java.lang.Integer> xlate
public SwingKeyboardReader()
translations
.public static final boolean isModifier(int key)
key
- The key code of the pressed keypublic static final boolean isSpecialCharacter(java.awt.event.KeyEvent evt)
evt
- The java generated keyboard event.public static final void mergeWithLastEvent(java.awt.event.KeyEvent last, java.awt.event.KeyEvent evt)
last
- The last key event in the keystrokes queue.evt
- The java keyboard eventpublic void insert(java.lang.String data)
data
- The "keys" to insert.public void keyPressed(java.awt.event.KeyEvent evt)
keyPressed
in interface java.awt.event.KeyListener
keyPressed
in class java.awt.event.KeyAdapter
evt
- the eventpublic void keyReleased(java.awt.event.KeyEvent evt)
keyReleased
in interface java.awt.event.KeyListener
keyReleased
in class java.awt.event.KeyAdapter
evt
- the eventpublic KeyCode read()
protected java.awt.event.KeyEvent findKeyEventByKeyCode(int keyCode)
keyCode
- The key event code