Shortcut
final class Shortcut
Package: dev.joid.lib.ui.shortcut · Module: core · Source: Shortcut.java
A key combination attached to a UI or a node that fires its listeners when the user presses it.
Description
Section titled “Description”A shortcut fires only while it is attached, and the Alt, Control and Shift keys must be exactly as set. By default it waits for the nodes: a focused text field that takes the key keeps it. The shortcuts of the visible and enabled nodes come first, from the front-most, then those of the UI; the first one that matches consumes the key.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
Shortcut | create(Object binding) factory | Creates a shortcut on a Key or on any value that a registered KeyResolver turns into a key. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| alt | boolean | false | If true, the shortcut fires only while Alt is down; if false, only while it is up. |
| ctrl | boolean | false | If true, the shortcut fires only while Control is down; if false, only while it is up. |
| shift | boolean | false | If true, the shortcut fires only while Shift is down; if false, only while it is up. |
| overrideFocus | boolean | false | If true, the shortcut fires before the nodes see the key, even when a text field has the focus. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | fireTrigger(Key key) | Runs the listeners of the shortcut as if this key had fired it. |
this | attach(UI ui) fluent | Attaches the shortcut to the UI; it leaves its previous owner first. |
this | attach(Node node) fluent | Attaches the shortcut to the node; it fires while the node is visible and enabled in an open UI. |
this | detach() fluent | Detaches the shortcut from its UI or its node. |
this | owner(UI ui, Node node) fluent | Records the owner of the shortcut. |
boolean | isAttached() | If true, the shortcut has a UI or a node. |
boolean | isTriggeredBy(Key key) | If true, the shortcut is attached, its binding resolves to this key and the modifier keys match. |
Object | getBinding() | The key or the value given to create. |
EventBus | getEventBus() | The listeners of the shortcut. |
UI | getUi() | The UI the shortcut is attached to, or null. |
Node | getNode() | The node the shortcut is attached to, or null. |
Events
Section titled “Events”| Event | Listener | Summary |
|---|---|---|
| onTrigger | EventListener<ShortcutEvent> | Adds a listener that runs on the render thread when the shortcut fires. |
Creation details
Section titled “Creation details”create
Section titled “create”Shortcut create(Object binding) factory
Creates a shortcut on a Key or on any value that a registered KeyResolver turns into a key.
In dev mode, a value that no resolver knows prints a warning; the shortcut fires once a resolver that knows it is registered.
Property details
Section titled “Property details”this alt(boolean alt)fluentboolean isAlt()
Default: false
If true, the shortcut fires only while Alt is down; if false, only while it is up.
this ctrl(boolean ctrl)fluentboolean isCtrl()
Default: false
If true, the shortcut fires only while Control is down; if false, only while it is up.
this shift(boolean shift)fluentboolean isShift()
Default: false
If true, the shortcut fires only while Shift is down; if false, only while it is up.
overrideFocus
Section titled “overrideFocus”this overrideFocus(boolean overrideFocus)fluentboolean isOverrideFocus()
Default: false
If true, the shortcut fires before the nodes see the key, even when a text field has the focus.
Method details
Section titled “Method details”fireTrigger
Section titled “fireTrigger”void fireTrigger(Key key)
Runs the listeners of the shortcut as if this key had fired it.
attach
Section titled “attach”this attach(UI ui) fluent
Attaches the shortcut to the UI; it leaves its previous owner first.
this attach(Node node) fluent
Attaches the shortcut to the node; it fires while the node is visible and enabled in an open UI.
detach
Section titled “detach”this detach() fluent
Detaches the shortcut from its UI or its node.
this owner(UI ui, Node node) fluent
Records the owner of the shortcut.
UI.addShortcut and Node.addShortcut call it; you attach with attach.
isAttached
Section titled “isAttached”boolean isAttached()
If true, the shortcut has a UI or a node.
isTriggeredBy
Section titled “isTriggeredBy”boolean isTriggeredBy(Key key)
If true, the shortcut is attached, its binding resolves to this key and the modifier keys match.
getBinding
Section titled “getBinding”Object getBinding()
The key or the value given to create.
getEventBus
Section titled “getEventBus”EventBus getEventBus()
The listeners of the shortcut.
UI getUi()
The UI the shortcut is attached to, or null.
getNode
Section titled “getNode”Node getNode()
The node the shortcut is attached to, or null.
Event details
Section titled “Event details”onTrigger
Section titled “onTrigger”this onTrigger(EventListener<ShortcutEvent> listener) fluent
Adds a listener that runs on the render thread when the shortcut fires.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
