public abstract class SwingKeyboardReader
extends java.awt.event.KeyAdapter
KeyAdapter.keyTyped(java.awt.event.KeyEvent)
and all other
key codes are handled by KeyAdapter.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<java.lang.Integer> |
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).
|
boolean |
isModifier(int key)
Tests if the given key code is a modifier.
|
boolean |
isSpecialCharacter(java.awt.event.KeyEvent evt)
Tests if the pressed key is @, ^, _ , \, ]
|
void |
keyReleased(java.awt.event.KeyEvent evt)
This method is called when a pressed key is released.
|
void |
mergeWithLastEvent(java.awt.event.KeyEvent last,
java.awt.event.KeyEvent evt)
Merges the java keyboard event with the last key event.
|
int |
read()
Read a keystroke from the key input buffer.
|
protected final java.util.Map<java.lang.Integer,java.lang.Integer> xlate
protected final java.util.concurrent.LinkedBlockingQueue<java.lang.Integer> queue
protected final java.util.Deque<java.awt.event.KeyEvent> keyDownEvents
public SwingKeyboardReader()
translations
.public final boolean isModifier(int key)
key
- The key code of the pressed keypublic 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 final boolean isSpecialCharacter(java.awt.event.KeyEvent evt)
evt
- The java generated keyboard event.public int read()
public void insert(java.lang.String data)
data
- The "keys" to insert.public void keyReleased(java.awt.event.KeyEvent evt)
WinKeyboardReader
.
Toggle-box (or other, possible) component must be able to process this
event of releasing key along with pressing.keyReleased
in interface java.awt.event.KeyListener
keyReleased
in class java.awt.event.KeyAdapter
evt
- The key event.protected java.awt.event.KeyEvent findKeyEventByKeyCode(int keyCode)
keyCode
- The key event code