- java.lang.Object
-
- javafx.scene.input.KeyCombination
-
- javafx.scene.input.KeyCharacterCombination
-
public final class KeyCharacterCombination extends KeyCombination
This class represents a key combination in which the main key is specified by its character. Such key combination is dependent on the keyboard functional layout configured by the user at the time of key combination matching.- Since:
- JavaFX 2.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javafx.scene.input.KeyCombination
KeyCombination.Modifier, KeyCombination.ModifierValue
-
-
Field Summary
-
Fields inherited from class javafx.scene.input.KeyCombination
ALT_ANY, ALT_DOWN, CONTROL_ANY, CONTROL_DOWN, META_ANY, META_DOWN, NO_MATCH, SHIFT_ANY, SHIFT_DOWN, SHORTCUT_ANY, SHORTCUT_DOWN
-
-
Constructor Summary
Constructors Constructor Description KeyCharacterCombination(String character, KeyCombination.Modifier... modifiers)
Constructs aKeyCharacterCombination
for the specified main key character and the specified list of modifiers.KeyCharacterCombination(String character, KeyCombination.ModifierValue shift, KeyCombination.ModifierValue control, KeyCombination.ModifierValue alt, KeyCombination.ModifierValue meta, KeyCombination.ModifierValue shortcut)
Constructs aKeyCharacterCombination
for the specified main key character and with an explicit specification of all modifier keys.
-
Method Summary
Modifier and Type Method Description boolean
equals(Object obj)
Tests whether thisKeyCharacterCombination
equals to the specified object.String
getCharacter()
Gets the key character associated with this key combination.String
getDisplayText()
Returns a string representation of thisKeyCombination
that is suitable for display in a user interface (for example, beside a menu item).String
getName()
Returns a string representation of thisKeyCharacterCombination
.int
hashCode()
Returns a hash code value for thisKeyCharacterCombination
.boolean
match(KeyEvent event)
Tests whether this key combination matches the key combination in the givenKeyEvent
.-
Methods inherited from class javafx.scene.input.KeyCombination
getAlt, getControl, getMeta, getShift, getShortcut, keyCombination, toString, valueOf
-
-
-
-
Constructor Detail
-
KeyCharacterCombination
public KeyCharacterCombination(String character, KeyCombination.ModifierValue shift, KeyCombination.ModifierValue control, KeyCombination.ModifierValue alt, KeyCombination.ModifierValue meta, KeyCombination.ModifierValue shortcut)
Constructs aKeyCharacterCombination
for the specified main key character and with an explicit specification of all modifier keys. Each modifier key can be set toPRESSED
,RELEASED
orIGNORED
.- Parameters:
character
- the main key charactershift
- the value of theshift
modifier keycontrol
- the value of thecontrol
modifier keyalt
- the value of thealt
modifier keymeta
- the value of themeta
modifier keyshortcut
- the value of theshortcut
modifier key
-
KeyCharacterCombination
public KeyCharacterCombination(String character, KeyCombination.Modifier... modifiers)
Constructs aKeyCharacterCombination
for the specified main key character and the specified list of modifiers. All modifier keys which are not explicitly listed are set to the defaultRELEASED
value.All possible modifiers which change the default modifier value are defined as constants in the
KeyCombination
class.- Parameters:
character
- the main key charactermodifiers
- the list of modifier keys and their corresponding values
-
-
Method Detail
-
getCharacter
public final String getCharacter()
Gets the key character associated with this key combination.- Returns:
- The key character associated with this key combination
-
match
public boolean match(KeyEvent event)
Tests whether this key combination matches the key combination in the givenKeyEvent
. The key character of this object is first translated to the key code which is capable of producing the character in the current keyboard layout and then the resulting key code together with the modifier keys are matched against the key code and key modifiers from theKeyEvent
. This means that the method can returntrue
only forKEY_PRESSED
andKEY_RELEASED
events, but not forKEY_TYPED
events, which don't have valid key codes.- Overrides:
match
in classKeyCombination
- Parameters:
event
- the key event- Returns:
true
if the key combinations match,false
otherwise
-
getName
public String getName()
Returns a string representation of thisKeyCharacterCombination
.The string representation consists of sections separated by plus characters. Each section specifies either a modifier key or the main key.
A modifier key section contains the
KeyCode
name of a modifier key. It can be prefixed with theIgnored
keyword. A non-prefixed modifier key implies itsPRESSED
value while the prefixed version implies theIGNORED
value. If some modifier key is not specified in the string at all, it means it has the defaultRELEASED
value.The main key section contains the main key character enclosed in single quotes and is the last section in the returned string.
- Overrides:
getName
in classKeyCombination
- Returns:
- the string representation of this
KeyCharacterCombination
-
getDisplayText
public String getDisplayText()
Returns a string representation of thisKeyCombination
that is suitable for display in a user interface (for example, beside a menu item).- Overrides:
getDisplayText
in classKeyCombination
- Returns:
- A string representation of this
KeyCombination
, suitable for display in a user interface.
-
equals
public boolean equals(Object obj)
Tests whether thisKeyCharacterCombination
equals to the specified object.- Overrides:
equals
in classKeyCombination
- Parameters:
obj
- the object to compare to- Returns:
true
if the objects are equal,false
otherwise
-
hashCode
public int hashCode()
Returns a hash code value for thisKeyCharacterCombination
.- Overrides:
hashCode
in classKeyCombination
- Returns:
- the hash code value
-
-