public final class KeyStroke extends Trigger implements Comparable
A KeyStroke
is defined as an optional set of modifier keys
followed optionally by a natural key. A KeyStroke
is said to
be complete if it contains a natural key. A natural key is any Unicode
character (e.g., "backspace", etc.), any character belonging to a natural
language (e.g., "A", "1", "[", etc.), or any special control character
specific to computers (e.g., "F10", "PageUp", etc.).
All KeyStroke
objects have a formal string representation
available via the toString()
method. There are a number of
methods to get instances of KeyStroke
objects, including one
which can parse this formal string representation.
All KeyStroke
objects, via the format()
method,
provide a version of their formal string representation translated by
platform and locale, suitable for display to a user.
KeyStroke
objects are immutable. Clients are not permitted to
extend this class.
Modifier and Type | Field and Description |
---|---|
static String |
KEY_DELIMITER
The delimiter between multiple keys in a single key strokes -- expressed
in the formal key stroke grammar.
|
static String |
KEY_DELIMITERS
The set of delimiters for
Key objects allowed during
parsing of the formal string representation. |
static int |
NO_KEY
The representation for no key.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Object object) |
boolean |
equals(Object object)
Tests whether this object is equal to another object.
|
String |
format()
Formats this key stroke into the current default look.
|
static KeyStroke |
getInstance(int naturalKey)
Creates an instance of
KeyStroke given a natural key. |
static KeyStroke |
getInstance(int modifierKeys,
int naturalKey)
Creates an instance of
KeyStroke given a set of modifier keys
and a natural key. |
static KeyStroke |
getInstance(String string)
Creates an instance of
KeyStroke by parsing a given a formal
string representation. |
int |
getModifierKeys()
Returns the modifier keys for this key stroke.
|
int |
getNaturalKey()
Returns the natural key for this key stroke.
|
int |
hashCode()
Computes the hash code for this object.
|
boolean |
isComplete()
Returns whether or not this key stroke is complete.
|
String |
toString()
Returns the formal string representation for this key stroke.
|
public static final String KEY_DELIMITER
public static final String KEY_DELIMITERS
Key
objects allowed during
parsing of the formal string representation.public static final int NO_KEY
public static final KeyStroke getInstance(int naturalKey)
KeyStroke
given a natural key.naturalKey
- the natural key. The format of this integer is defined by
whichever widget toolkit you are using; NO_KEY
always means no natural key.null
.SWTKeySupport
public static final KeyStroke getInstance(int modifierKeys, int naturalKey)
KeyStroke
given a set of modifier keys
and a natural key.modifierKeys
- the modifier keys. The format of this integer is defined by
whichever widget toolkit you are using; NO_KEY
always means no modifier keys.naturalKey
- the natural key. The format of this integer is defined by
whichever widget toolkit you are using; NO_KEY
always means no natural key.null
.SWTKeySupport
public static final KeyStroke getInstance(String string) throws ParseException
KeyStroke
by parsing a given a formal
string representation.string
- the formal string representation to parse.null
.ParseException
- if the given formal string representation could not be parsed
to a valid key stroke.public final int compareTo(Object object)
compareTo
in interface Comparable
public final boolean equals(Object object)
Trigger
public final String format()
null
.public final int getModifierKeys()
NO_KEY
means that
there is no modifier key.public final int getNaturalKey()
NO_KEY
if the key stroke is incomplete (i.e., has
no natural key).public final int hashCode()
Trigger
public final boolean isComplete()
NO_KEY
.true
, iff the key stroke is complete.public final String toString()
toString
in class Object
null
.Object.toString()
Guidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.