com.vaadin.flow.component.
Class Shortcuts
- java.lang.Object
-
- com.vaadin.flow.component.Shortcuts
-
public final class Shortcuts extends Object
Collections of methods for configuring more complex Shortcut interactions.
Unlike the shortcut methods offered by
Focusable
andClickNotifier
, these methods allow for configuring thelifecycleOwner
directly, making it possible to added the shortcut onto any component. ThelifecycleOwner
denotes the component to which the shortcut is bound to. If the lifecycle owner is not attached, visible, or enabled, the shortcut won't work, and vice-versa.Since:
1.3
Author:
Vaadin Ltd.
See Also:
for adding a shortcut for focusing the component
,for adding a shortcut which performs the click-action
-
-
Method Summary
All Methods Modifier and Type Method and Description static ShortcutRegistration
addShortcutListener(Component lifecycleOwner, Command command, Key key, KeyModifier... keyModifiers)
Invoke a
Command
when the shortcut is invoked.static ShortcutRegistration
addShortcutListener(Component lifecycleOwner, ShortcutEventListener listener, Key key, KeyModifier... keyModifiers)
Invoke a
ShortcutEventListener
when the shortcut is invoked.
-
-
-
Method Detail
-
addShortcutListener
public static ShortcutRegistration addShortcutListener(Component lifecycleOwner, Command command, Key key, KeyModifier... keyModifiers)
Invoke a
Command
when the shortcut is invoked.Registering a shortcut using this method will tie it to
lifecycleOwner
and the shortcut is available in the global scope.By default, the shortcut's listener is bound to
UI
. The listening component can be changed by callingShortcutRegistration.listenOn(Component)
.Parameters:
lifecycleOwner
- the component that controls, when the shortcut is active. If the component is either invisible or detached, the shortcut won't work. Cannot benull
command
- code to execute when the shortcut is invoked. Cannot benull
key
- primaryKey
used to trigger the shortcut. Cannot benull
keyModifiers
-KeyModifiers
which also need to be pressed for the shortcut to triggerReturns:
ShortcutRegistration
for configuring and removing the shortcut
-
addShortcutListener
public static ShortcutRegistration addShortcutListener(Component lifecycleOwner, ShortcutEventListener listener, Key key, KeyModifier... keyModifiers)
Invoke a
ShortcutEventListener
when the shortcut is invoked.Registering a shortcut using this method will tie it to
lifecycleOwner
and the shortcut is available in the global scope.By default, the shortcut's listener is bound to
UI
. The listening component can be changed by callingShortcutRegistration.listenOn(Component)
.Parameters:
lifecycleOwner
- the component that controls, when the shortcut is active. If the component is either invisible or detached, the shortcut won't work. Cannot benull
listener
- listener to execute when the shortcut is invoked. Receives aShortcutEvent
. Cannot benull
key
- primaryKey
used to trigger the shortcut. Cannot benull
keyModifiers
-KeyModifiers
which also need to be pressed for the shortcut to triggerReturns:
ShortcutRegistration
for configuring and removing the shortcut
-
-