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()
Component which owns the shortcuts key event listener. |
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 listenOnComponent)
Fluently define the
Component onto which the shortcut's listener
is bound. |
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. |
public 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)
Component onto which the shortcut's listener
is bound. Calling this method will remove the previous listener from the
component it was bound to.listenOnComponent - Component onto which the shortcut
listener is bound.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.@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 propagationpublic Component getOwner()
Component which owns the shortcuts key event listener.public Component getLifecycleOwner()
Component which controls when the shortcut is active and when it
is not.isShortcutActive()Copyright © 2000–2019 Vaadin Ltd. All rights reserved.