Class KeyCombination

java.lang.Object
io.jmix.flowui.kit.component.KeyCombination

public class KeyCombination extends Object
Stores information about key, modifiers and additional settings that describe shortcut combinations.
  • Field Details

    • KEY_FIELD_PREFIX

      protected static final String KEY_FIELD_PREFIX
      See Also:
    • key

      protected final com.vaadin.flow.component.Key key
    • keyModifiers

      protected final com.vaadin.flow.component.KeyModifier[] keyModifiers
    • listenOnComponents

      protected com.vaadin.flow.component.Component[] listenOnComponents
    • resetFocusOnActiveElement

      protected boolean resetFocusOnActiveElement
  • Constructor Details

    • KeyCombination

      protected KeyCombination(com.vaadin.flow.component.Key key, com.vaadin.flow.component.KeyModifier... keyModifiers)
  • Method Details

    • getKey

      public com.vaadin.flow.component.Key getKey()
      Returns:
      keyboard key
    • getKeyModifiers

      @Nullable public com.vaadin.flow.component.KeyModifier[] getKeyModifiers()
      Returns:
      modifier keys
    • getListenOnComponents

      @Nullable public com.vaadin.flow.component.Component[] getListenOnComponents()
      Returns:
      components onto which the shortcut listeners are bound
    • isResetFocusOnActiveElement

      public boolean isResetFocusOnActiveElement()
      Returns:
      true if the focus should be reset for the active focused element, false otherwise
    • setResetFocusOnActiveElement

      public void setResetFocusOnActiveElement(boolean resetFocusOnActiveElement)
      Reset the focus for active focused element. Lose focus (i.e., it’s blurred) and receive focus again before a shortcut is triggered for this key combination. This ensures any pending input value change events for that focused element are submitted before a shortcut is activated.
      The resetFocusOnActiveElement is false by default.
      Parameters:
      resetFocusOnActiveElement - whether to reset focus
    • create

      public static KeyCombination create(com.vaadin.flow.component.Key key, com.vaadin.flow.component.KeyModifier... keyModifiers)
      Creates a new KeyCombination instance from passed Key and modifiers.
      Parameters:
      key - primary Key used to trigger the shortcut
      keyModifiers - KeyModifiers that need to be pressed along with the key for the shortcut to trigger
      Returns:
      new instance
    • create

      @Nullable public static KeyCombination create(@Nullable String keyString)
      Creates a new KeyCombination instance from a string representation.
      Parameters:
      keyString - string of type "Modifiers-Key", e.g. "Alt-N". Case-insensitive.
      Returns:
      new instance
    • create

      @Nullable public static KeyCombination create(@Nullable String keyString, com.vaadin.flow.component.Component... listenOnComponents)
      Creates a new KeyCombination instance from a string representation.
      Parameters:
      keyString - string of type "Modifiers-Key", e.g. "Alt-N". Case-insensitive.
      listenOnComponents - Components onto which the shortcut listeners are bound. Must not be null. Must not contain null. Must not have duplicate components. Must be Focusable, or its nested components must be Focusable. For components that do not support focus, the KeyCombination will only fire if its nested components have focus.
      Returns:
      new instance
    • valueOf

      public static com.vaadin.flow.component.Key valueOf(String keyString)
      Parses a new Key from a string representation.
      Parameters:
      keyString - a string representing Key object, e.g. "Alt", "L"
      Returns:
      a Key representing passed string
    • format

      public String format()
      Returns:
      a string representation of this KeyCombination, e.g. Alt+L
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object