Package com.luciad.input
Class ModifierKeys
java.lang.Object
com.luciad.input.ModifierKeys
Utility class that contains the combination of the modifier keys pressed.
The modifiers keys are mapped to the following values:
- None => 0
- Alt => 1
- Ctrl => 2
- Shift => 4
- Note
- Don't use the
hasFlagmethod if you want to check that there are no modifiers set, instead do
ModifierKeys shift = ModifierKeys.Shift;
boolean checkNone = shift.equals(ModifierKeys.None);
assertFalse(checkNone);
ModifierKeys none = ModifierKeys.None;
checkNone = none.equals(ModifierKeys.None);
assertTrue(checkNone);
An example usage is:
ModifierKeys ctrl = ModifierKeys.Ctrl;
ModifierKeys alt = ModifierKeys.Alt;
ModifierKeys ctrlAlt = ctrl.or(alt);
boolean isNone = ctrlAlt.equals(ModifierKeys.None);
boolean isAlt = ctrlAlt.hasFlag(ModifierKeys.Alt);
boolean isCtrlAlt = ctrlAlt.equals(ModifierKeys.Alt.or(ModifierKeys.Ctrl));
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ModifierKeysAModifierKeysinstance that represents the Alt modifier key.static final ModifierKeysAModifierKeysinstance that represents the Ctrl modifier key.static final ModifierKeysAModifierKeysinstance that represents no modifier keys.static final ModifierKeysAModifierKeysinstance that represents the Shift modifier key. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionand(ModifierKeys other) booleanlonggetKeys()Returns the combined pressed modifier keys.booleanhasFlag(ModifierKeys keys) Returns if the specified modifier keys are pressed.inthashCode()or(ModifierKeys other)
-
Field Details
-
None
AModifierKeysinstance that represents no modifier keys. -
Alt
AModifierKeysinstance that represents the Alt modifier key. -
Ctrl
AModifierKeysinstance that represents the Ctrl modifier key. -
Shift
AModifierKeysinstance that represents the Shift modifier key.
-
-
Constructor Details
-
ModifierKeys
public ModifierKeys(long keys) Creates a new instance.- Parameters:
keys- the bits that represent the modifier keys.
-
-
Method Details
-
and
-
or
-
hasFlag
Returns if the specified modifier keys are pressed.- Parameters:
keys-- Returns:
- if the keys are pressed
-
getKeys
public long getKeys()Returns the combined pressed modifier keys.- Returns:
- the combined pressed modifier keys.
-
equals
-
hashCode
public int hashCode()
-