Class ShortcutTrigger
java.lang.Object
com.vaadin.flow.component.trigger.AbstractTrigger
com.vaadin.flow.component.trigger.ShortcutTrigger
- All Implemented Interfaces:
Trigger,Serializable
Fires when the given key (with optional modifiers) is pressed while the host
element is the active scope. The shortcut listens for
keydown events
that originate inside the host element, matching event.key against
the configured Key and event.ctrlKey / altKey / shiftKey /
metaKey against the configured KeyModifier set.
Bound actions run inside the keydown handler, preserving the user-gesture context.
new ShortcutTrigger(form, Key.ENTER, KeyModifier.CONTROL)
.triggers(new ClickAction(submitButton));
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionShortcutTrigger(Component host, Key key, KeyModifier... modifiers) Creates a shortcut trigger bound to the given host component's root element.ShortcutTrigger(Element host, Key key, KeyModifier... modifiers) Creates a shortcut trigger bound to the given host element. -
Method Summary
Modifier and TypeMethodDescriptiontools.jackson.databind.node.ObjectNodebuildClientConfig(ConfigContext context) Produces the JSON configuration this trigger sends to the client.getKey()Methods inherited from class com.vaadin.flow.component.trigger.AbstractTrigger
getHost, getTriggerId, getTypeId, remove, triggers, triggers
-
Field Details
-
TYPE_ID
- See Also:
-
-
Constructor Details
-
ShortcutTrigger
Creates a shortcut trigger bound to the given host element.- Parameters:
host- the element acting as the shortcut's scope, notnullkey- the key to listen for, notnullmodifiers- modifier keys that must be held; empty for none
-
ShortcutTrigger
Creates a shortcut trigger bound to the given host component's root element.- Parameters:
host- the component acting as the shortcut's scope, notnullkey- the key to listen for, notnullmodifiers- modifier keys that must be held; empty for none
-
-
Method Details
-
getKey
- Returns:
- the key this shortcut listens for
-
getModifiers
- Returns:
- an unmodifiable view of the modifier set
-
buildClientConfig
Description copied from class:AbstractTriggerProduces the JSON configuration this trigger sends to the client. Default is an empty object; override to add type-specific options.The
contextlets subclasses encode element/output references by id when needed. Public so the internal framework can read the config without reflection; subclasses just override.- Overrides:
buildClientConfigin classAbstractTrigger- Parameters:
context- the resolver for referenced elements and outputs, notnull- Returns:
- a Jackson
ObjectNode, nevernull
-