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
Component onto which the shortcut's listener
is bound. |
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.
|
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... listenOnComponents)
Component onto which the shortcut's listener
is bound. Calling this method will remove the previous listener from the
component it was bound to.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 Registrationpublic boolean isShortcutActive()
public Key getKey()
Key of the shortcut. Primary key can be any key
besides modifier keys.public 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 keydownpublic 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 © 2021. All rights reserved.