Component to help create shortcuts over Node objects.
To help Shortcut implementation and increase legibility it was created Keys class which is class that permits to collect Key objects. An Key object has 3 fields :
private final CommandKey[] commandKeys : secundary keysprivate final KeyCode code : shortcut keyprivate final Consumer<KeyEvent> action : action to be executedThis 3 fields are setted on constructor and can be obtained via getter methods.
public Shortcut(T node, Keys keys, boolean keepOldHandler, boolean receiveChildEvents)
There are more constructors with different parameters, but all will internally call this first one.
Variations :
boolean keepOldHandler this value will be assumed as true.boolean receiveChildEvents this value will be assumed as false.Collection<Pair<KeyCode, Runnable>> actions will instantiate Keys object with it.IComponent<T> component obtain Node object from component.getNode().public Shortcut(T node, Keys keys, boolean keepOldHandler)
public Shortcut(T node, Keys keys)
public Shortcut(T node, Collection<Pair<KeyCode, Runnable>> actions, boolean keepOldHandler)
public Shortcut(T node, Collection<Pair<KeyCode, Runnable>> actions)
public Shortcut(IComponent<T> component, Keys keys, boolean keepOldHandler)
public Shortcut(IComponent<T> component, Keys keys)
public Shortcut(IComponent<T> component, Collection<Pair<KeyCode, Runnable>> actions, boolean keepOldHandler)
public Shortcut(IComponent<T> component, Collection<Pair<KeyCode, Runnable>> actions)
Pane pane;
Button button;
Keys keys = new Keys();
keys.add(KeyCode.DELETE, ()->pane.getChildren().remove(button));
new Shortcut<>(button, keys).mount();