staffui
Class MagicKeyListener
java.lang.Object
staffui.MagicKeyListener
- All Implemented Interfaces:
- KeyListener, EventListener
public class MagicKeyListener
- extends Object
- implements KeyListener
A MagicKeyListener is decorator for a KeyListener.
This class adds three pieces of functionality. First, it delays
key events (moving them to the back of the event queue). Second,
it maintains state so that when a press-and-release event pair is
sitting in the queue, neither event is propogated to the adaptee
(decoratee). Finally, it can (optionally) add to the semantics so
that any release event implies that any still-pressed keys have
also been released.
Together, these additions may provide more meaningful semantics
of key listening in an environment where a key being held down
generates repeated key events, or where multiple keys pressed
generate a release event for only one of them.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MagicKeyListener
public MagicKeyListener(KeyListener adaptee)
- Requires:
- adaptee != null
- Effects:
- creates a new MagicKeyListener without the generation of
additional key release events (the third option given in the
class overview is disabled).
MagicKeyListener
public MagicKeyListener(KeyListener adaptee,
boolean assumeAllReleased)
- Parameters:
assumeAllReleased
- enables the third option listed in the
class overview, namely that any key release event implies that
all keys have been released.- Requires:
- adaptee != null
- Effects:
- creates a new MagicKeyListener.
keyPressed
public void keyPressed(KeyEvent e)
- Specified by:
keyPressed
in interface KeyListener
- Effects:
- Acts on the given event as specified in the class overview.
keyReleased
public void keyReleased(KeyEvent e)
- Specified by:
keyReleased
in interface KeyListener
- Effects:
- Acts on the given event as specified in the class overview.
keyTyped
public void keyTyped(KeyEvent e)
- Specified by:
keyTyped
in interface KeyListener
- Effects:
- Acts on the given event as specified in the class overview