ewe.ui
Class KeyEvent

java.lang.Object
  extended byewe.ui.Event
      extended byewe.ui.KeyEvent

public class KeyEvent
extends Event

KeyEvent is a key press event.


Field Summary
 int key
          The key pressed or entered by other means (grafitti input).
static int KEY_PRESS
          The event type for a key press event.
static int KEY_RELEASE
           
 int modifiers
          The state of the modifier keys when the event occured.
 String text
          This is used if a key or key-combination as pressed by the user has resulted in the generation of a multiple character string.
 int textReplacement
          This is used with the MULTICHARACTER modifier.
 
Fields inherited from class ewe.ui.Event
consumed, events, flags, target, timeStamp, type, window
 
Constructor Summary
KeyEvent()
           
 
Method Summary
 void controlToLetter()
          Convert specific control keys to their letter counterpart.
static int getActionKey(boolean forHotKey)
           
static int getBackKey(boolean forHotKey)
           
static int getCancelKey(boolean forHotKey)
           
static boolean hasModifier(int key)
          Checks to see if a hot-key encoded key has a modifier.
 boolean isActionKey()
           
 boolean isBackKey()
           
 boolean isCancelKey()
           
 boolean isHotKey(int controlHotKey)
          Checks to see if the key represented by this KeyEvent should be considered to match the hot-key of a particular Control.
static boolean isHotKey(int key, int controlHotKey)
          Checks to see if the pressed hot-key should be considered to match the hot-key of a particular Control.
 boolean isMoveToNextControlKey(boolean moveForwards)
           
 void keypadToKey()
          Convert a KEYPAD_ type key into a standard key.
 int toKey()
          Convert this KeyEvent into a hot-key encoded key code.
static int toKey(int modifier, char character)
          The produces a key code that can be used as a "Hot Key" for a Control.
static int toKey(int modifier, int key)
          The produces a key code that can be used as a "Hot Key" for a Control.
static String toString(int key)
          Print a String representation of a key.
 
Methods inherited from class ewe.ui.Event
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 

Field Detail

KEY_PRESS

public static final int KEY_PRESS
The event type for a key press event.

See Also:
Constant Field Values

KEY_RELEASE

public static final int KEY_RELEASE
See Also:
Constant Field Values

key

public int key
The key pressed or entered by other means (grafitti input). This is either a normal character key (if the value is < 70000) or one of the special keys defined in the IKeys interface.

See Also:
IKeys

text

public String text
This is used if a key or key-combination as pressed by the user has resulted in the generation of a multiple character string. This value is placed in text and the IKeys.MULTICHARACTER modifier will be set.


textReplacement

public int textReplacement
This is used with the MULTICHARACTER modifier. It indicates how many, if any, of the last set of characters already input should be erased before the new text is appended. If the value is -1 this indicates that all characters should be erased.


modifiers

public int modifiers
The state of the modifier keys when the event occured. This is a OR'ed combination of the modifiers present in the IKeys interface.

See Also:
IKeys
Constructor Detail

KeyEvent

public KeyEvent()
Method Detail

controlToLetter

public void controlToLetter()
Convert specific control keys to their letter counterpart. For example the key is converted to 'I'


keypadToKey

public void keypadToKey()
Convert a KEYPAD_ type key into a standard key.


toString

public static final String toString(int key)
Print a String representation of a key.

Parameters:
key - A key as provided in a KeyEvent.
Returns:
A String representation of the key.

toKey

public static final int toKey(int modifier,
                              char character)
The produces a key code that can be used as a "Hot Key" for a Control.

Parameters:
modifier - Any of the IKeys.SHIFT, IKeys.CONTROL, IKeys.ONLY ORed together.

If none of these modifiers are used then when the character is pressed with ANY of SHIFT or CONTROL keys, the hot key will be activated. If IKeys.ONLY is specified then the character must be pressed ALONE for the hot key to be activated.

character - The character for the key.
Returns:
A key code that can be used as the hot key for a control.

toKey

public static final int toKey(int modifier,
                              int key)
The produces a key code that can be used as a "Hot Key" for a Control.

Parameters:
modifier - Any of the IKeys.SHIFT, IKeys.CONTROL, IKeys.ONLY ORed together.

If none of these modifiers are used then when the character is pressed with ANY of SHIFT or CONTROL keys, the hot key will be activated. If IKeys.ONLY is specified then the character must be pressed ALONE for the hot key to be activated.

key - The key code for the key. You can use one of the IKeys key codes such as F1, HOME, etc.
Returns:
A key code that can be used as the hot key for a control.

hasModifier

public static final boolean hasModifier(int key)
Checks to see if a hot-key encoded key has a modifier. You would most likely not call this method directly.

Parameters:
key - The hot-key encoded key code.
Returns:
true if SHIFT or CONTROL has been pressed with the key.

isHotKey

public static final boolean isHotKey(int key,
                                     int controlHotKey)
Checks to see if the pressed hot-key should be considered to match the hot-key of a particular Control.

Parameters:
key - The pressed key.
controlHotKey - The assigned hot-key of a Control
Returns:
true if the pressed key should be considered a match to the Control's hot-key.

isHotKey

public final boolean isHotKey(int controlHotKey)
Checks to see if the key represented by this KeyEvent should be considered to match the hot-key of a particular Control.

Parameters:
controlHotKey - The assigned hot-key of a Control
Returns:
true if the pressed key should be considered a match to the Control's hot-key.

toKey

public final int toKey()
Convert this KeyEvent into a hot-key encoded key code.


isBackKey

public boolean isBackKey()

isActionKey

public boolean isActionKey()

isMoveToNextControlKey

public boolean isMoveToNextControlKey(boolean moveForwards)

isCancelKey

public boolean isCancelKey()

getBackKey

public static int getBackKey(boolean forHotKey)

getCancelKey

public static int getCancelKey(boolean forHotKey)

getActionKey

public static int getActionKey(boolean forHotKey)