public class ShortcutRegistration extends Object implements Registration, Serializable
| Modifier and Type | Method and Description |
|---|---|
ShortcutRegistration |
allowBrowserDefault()
Allows the default keyboard event handling when the shortcut is invoked.
|
ShortcutRegistration |
allowEventPropagation()
Allow the event to propagate upwards in the DOM tree, when the shortcut
is invoked.
|
ShortcutRegistration |
bindLifecycleTo(Component component)
Binds the shortcut's life cycle to that of the given
Component. |
Key |
getKey()
Get the primary
Key of the shortcut. |
Component |
getLifecycleOwner()
Component which controls when the shortcut is active and when it
is not. |
Set<Key> |
getModifiers()
|
Component |
getOwner()
Deprecated.
This component has now multiple owners so this method has
been replaced by #getOwners().
|
Component[] |
getOwners()
The
Components which own the shortcuts key event listeners. |
boolean |
isBrowserDefaultAllowed()
Checks if the default key behaviour in the browser is allowed by the
shortcut.
|
boolean |
isEventPropagationAllowed()
Checks if the shortcut allows keydown event (associated with the
shortcut) propagation in the browser.
|
boolean |
isShortcutActive()
Is the shortcut active on the current UI.
|
ShortcutRegistration |
listenOn(Component... listenOnComponents)
Fluently define the components to listen for shortcuts on.
|
ShortcutRegistration |
listenOn(Component listenOnComponent)
Fluently define the component to listen for shortcuts on.
|
boolean |
preventsDefault()
Deprecated.
Replaced by
isBrowserDefaultAllowed() in 1.4 |
void |
remove()
Removes the
ShortcutRegistration |
void |
setBrowserDefaultAllowed(boolean browserDefaultAllowed)
Set whether the default key behavior is allowed in the browser.
|
void |
setEventPropagationAllowed(boolean eventPropagationAllowed)
Set whether shortcut's keydown event is allowed to propagate up the DOM
tree in the browser.
|
boolean |
stopsPropagation()
Deprecated.
Replaced by
isEventPropagationAllowed() in 1.4 |
String |
toString() |
ShortcutRegistration |
withAlt()
Fluently adds
KeyModifier.ALT to the shortcut's modifiers. |
ShortcutRegistration |
withCtrl()
Fluently adds
KeyModifier.CONTROL to the shortcut's modifiers. |
ShortcutRegistration |
withMeta()
Fluently adds
KeyModifier.META to the shortcut's modifiers. |
ShortcutRegistration |
withModifiers(KeyModifier... keyModifiers)
Configures
KeyModifiers for the shortcut. |
ShortcutRegistration |
withShift()
Fluently adds
KeyModifier.SHIFT to the shortcut's modifiers. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddAndRemove, combine, oncepublic ShortcutRegistration withModifiers(KeyModifier... keyModifiers)
KeyModifiers for the shortcut. Calling
this method will overwrite any previously set modifier keys. Hence,
calling shortcutRegistration.withModifiers(); will remove all
previously set modifier keys.keyModifiers - Key modifiers. Can be empty.ShortcutRegistrationpublic ShortcutRegistration withAlt()
KeyModifier.ALT to the shortcut's modifiers.ShortcutRegistrationpublic ShortcutRegistration withCtrl()
KeyModifier.CONTROL to the shortcut's modifiers.ShortcutRegistrationpublic ShortcutRegistration withMeta()
KeyModifier.META to the shortcut's modifiers.ShortcutRegistrationpublic ShortcutRegistration withShift()
KeyModifier.SHIFT to the shortcut's modifiers.ShortcutRegistrationpublic ShortcutRegistration allowBrowserDefault()
ShortcutRegistrationsetBrowserDefaultAllowed(boolean)public ShortcutRegistration allowEventPropagation()
ShortcutRegistrationsetEventPropagationAllowed(boolean)public ShortcutRegistration bindLifecycleTo(Component component)
Component.
When the given component is attached, the shortcut's listener is
attached to the Component that owns the shortcut. When the given
component is detached, so is the listener. is detached, the
shortcut is removed from all attached scopes.component - New lifecycle owner of the shortcutShortcutRegistrationpublic ShortcutRegistration listenOn(Component listenOnComponent)
This method only exists to retain backwards compatibility after support
for listening on multiple components was added with the method
listenOn(Component...).
listenOnComponent - components to listen for the shortcut on. Must not be null.ShortcutRegistrationpublic ShortcutRegistration listenOn(Component... listenOnComponents)
listenOnComponents - Components onto which the shortcut listeners are
bound. Must not be null. Must not contain null. Must not have
duplicate components.ShortcutRegistrationpublic void remove()
ShortcutRegistration
Removes all the underlying registrations tied to owner and lifecycle
owner components.
remove in interface RegistrationRegistration.once(Command)public boolean isShortcutActive()
public Key getKey()
Key of the shortcut. Primary key can be any key
besides modifier keys.@Deprecated public boolean preventsDefault()
isBrowserDefaultAllowed() in 1.4public boolean isBrowserDefaultAllowed()
false.public void setBrowserDefaultAllowed(boolean browserDefaultAllowed)
false, and it prevents the default key events
from taking place in the browser.browserDefaultAllowed - Allow default behavior on keydown@Deprecated public boolean stopsPropagation()
isEventPropagationAllowed() in 1.4public boolean isEventPropagationAllowed()
false.public void setEventPropagationAllowed(boolean eventPropagationAllowed)
false, and the DOM
event is consumed by the shortcut handler.eventPropagationAllowed - Allow event propagation@Deprecated public Component getOwner()
Component which owns the first shortcuts key event listener.public Component[] getOwners()
Components which own the shortcuts key event listeners.public Component getLifecycleOwner()
Component which controls when the shortcut is active and when it
is not.isShortcutActive()Copyright © 2025. All rights reserved.