Interface Focusable<T extends Component>

Type Parameters:
T - the type of the component which implements the interface
All Superinterfaces:
BlurNotifier<T>, FocusNotifier<T>, HasElement, HasEnabled, Serializable
All Known Implementing Classes:
RouterLink

public interface Focusable<T extends Component> extends HasElement, BlurNotifier<T>, FocusNotifier<T>, HasEnabled
Represents a component that can gain and lose focus.
Since:
1.0
Author:
Vaadin Ltd.
See Also:
  • Method Details

    • setTabIndex

      default void setTabIndex(int tabIndex)
      Sets the tabindex attribute in the component. The tabIndex indicates if its element can be focused, and if/where it participates in sequential keyboard navigation:
      • A negative value (usually tabindex = -1 means that the component should be focusable, but should not be reachable via sequential keyboard navigation.
      • tabindex = 0 means that the component should be focusable in sequential keyboard navigation, but its order is defined by the document's source order.
      • A positive value means the component should be focusable in sequential keyboard navigation, with its order defined by the value of the number. That is, tabindex = 4 would be focused before tabindex = 5, but after tabindex = 3. If multiple components share the same positive tabindex value, their order relative to each other follows their position in the document source.
      Parameters:
      tabIndex - the tabindex attribute
      See Also:
    • getTabIndex

      default int getTabIndex()
      Gets the tabindex in the component. The tabIndex indicates if its element can be focused, and if/where it participates in sequential keyboard navigation.

      If there's no such attribute set, it returns the default setting for the element, which depends on the element and on the browser. If the attribute cannot be parsed to int, then an IllegalStateException is thrown.

      Returns:
      the tabindex attribute, or 0 if none
      Throws:
      IllegalStateException - if the returned tabindex from the element is empty or can not be parsed to int
      See Also:
    • focus

      default void focus()
      Calls the focus function at the client, making the component keyboard focused.
      See Also:
    • blur

      default void blur()
      Calls the blur function at the client, making the component lose keyboard focus.
      See Also:
    • addFocusShortcut

      default ShortcutRegistration addFocusShortcut(Key key, KeyModifier... keyModifiers)
      Adds a shortcut which focuses the Component which implements Focusable interface. The shortcut's event listener is in global scope and the shortcut's lifecycle is tied to this component.

      Use the returned ShortcutRegistration to fluently configure the shortcut.

      Parameters:
      key - primary Key used to trigger the shortcut. Cannot be null.
      keyModifiers - KeyModifiers that need to be pressed along with the key for the shortcut to trigger
      Returns:
      ShortcutRegistration for configuring the shortcut and removing