Class J3Key
KeyBindings.
A J3Key can be identified within KeyBindings.getActionMap() or KeyBindings.getInputMap()
via it's UUID.
This can either be a keystroke to do one task, which can have its action switched out for something else temporarily. Say if you have some key which works on W and you'd like to switch it to work for something else and then switch it back to normal.
A J3Key can also represent a one shot key where it deregisters itself after clicking.
A J3key can also be linked to other keys. See GlobalKeybinds.SELECT_SUBTRACT_DOWN
for example which is the leader of a 4 keychain link. If it's I keybind is changed,
the children will also change along with their own respective keycode.
e.g. if I changes to G+SHIFT, and it was linked to I+CTRL,
that will change to the new parent's code plus the child's original modifiers G+SHIFT+CTRL.
In a chain the leader's KeyEvent is what will cascade and not a child's parent.
It is vital that if you use linking, the parent node (often referred to in these docs as the leader)
should not be identical to any other child node. See KeyBindings.childModifiersClash(J3Key)
however to summarise, a leader keyStroke's AWTKeyStroke.getModifiers() AND AWTKeyStroke.isOnKeyRelease()
cannot clash with any one of the children defined within the chain.
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcall(ActionEvent e) Calls the current action.Returns the action of the key.getId()Returns the id of the key used for identification withinKeyBindings.getActionMap()andKeyBindings.getInputMap().Returns the keystroke of the key.getLink()Returns the child link of this key.getName()Returns the name of the key.booleanWhether the action of this key was replaced temporarily.booleanWhether this key will only execute once or not.Marks another key as the child link of this key.replaceAction(Action newAction) Replaces this key's original action with a new temporary actionResets the action, if replaced, to its normal value.Sets the action of this key.setKeyStroke(KeyStroke keyStroke) Sets the keystroke of this keySets the name of the key.
-
Field Details
-
name
-
id
-
keyStroke
-
oldAction
-
action
-
actionReplaced
private boolean actionReplaced -
oneShot
private boolean oneShot -
link
-
-
Constructor Details
-
J3Key
Default J3Key constructor- Parameters:
name- the name of the keyoneShot- whether the key is only executed once before being removed.
-
J3Key
-
-
Method Details
-
linkTo
-
getName
-
getKeyStroke
-
getAction
-
getId
Returns the id of the key used for identification withinKeyBindings.getActionMap()andKeyBindings.getInputMap().- Returns:
- the id of the key
-
getLink
-
isActionReplaced
public boolean isActionReplaced()Whether the action of this key was replaced temporarily.- Returns:
- whether the action of this key was replaced temporarily
-
isOneShot
public boolean isOneShot()Whether this key will only execute once or not.- Returns:
- whether this key will only execute once or not
-
setName
-
setKeyStroke
-
setAction
-
replaceAction
-
resetAction
Resets the action, if replaced, to its normal value.- Returns:
- this key for method chaining
-
call
-
setId
-