Skip to content

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.

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.

ReturnsSignatureSummary
Shortcutcreate(Object binding) factoryCreates a shortcut on a Key or on any value that a registered KeyResolver turns into a key.

PropertyTypeDefaultSummary
altbooleanfalseIf true, the shortcut fires only while Alt is down; if false, only while it is up.
ctrlbooleanfalseIf true, the shortcut fires only while Control is down; if false, only while it is up.
shiftbooleanfalseIf true, the shortcut fires only while Shift is down; if false, only while it is up.
overrideFocusbooleanfalseIf true, the shortcut fires before the nodes see the key, even when a text field has the focus.

ReturnsSignatureSummary
voidfireTrigger(Key key)Runs the listeners of the shortcut as if this key had fired it.
thisattach(UI ui) fluentAttaches the shortcut to the UI; it leaves its previous owner first.
thisattach(Node node) fluentAttaches the shortcut to the node; it fires while the node is visible and enabled in an open UI.
thisdetach() fluentDetaches the shortcut from its UI or its node.
thisowner(UI ui, Node node) fluentRecords the owner of the shortcut.
booleanisAttached()If true, the shortcut has a UI or a node.
booleanisTriggeredBy(Key key)If true, the shortcut is attached, its binding resolves to this key and the modifier keys match.
ObjectgetBinding()The key or the value given to create.
EventBusgetEventBus()The listeners of the shortcut.
UIgetUi()The UI the shortcut is attached to, or null.
NodegetNode()The node the shortcut is attached to, or null.

EventListenerSummary
onTriggerEventListener<ShortcutEvent>Adds a listener that runs on the render thread when the shortcut fires.

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.

  • this alt(boolean alt) fluent
  • boolean isAlt()

Default: false

If true, the shortcut fires only while Alt is down; if false, only while it is up.

  • this ctrl(boolean ctrl) fluent
  • boolean isCtrl()

Default: false

If true, the shortcut fires only while Control is down; if false, only while it is up.

  • this shift(boolean shift) fluent
  • boolean isShift()

Default: false

If true, the shortcut fires only while Shift is down; if false, only while it is up.

  • this overrideFocus(boolean overrideFocus) fluent
  • boolean isOverrideFocus()

Default: false

If true, the shortcut fires before the nodes see the key, even when a text field has the focus.

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. UI.addShortcut and Node.addShortcut call it; you attach with attach.

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.

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

Report a problem with this page