com.vaadin.flow.component.
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:
AbstractNumberField
, Anchor
, BigDecimalField
, Button
, Checkbox
, CollaborationMessageInput
, ComboBox
, ComboBoxBase
, CrudGrid
, CustomField
, DatePicker
, DateTimePicker
, DrawerToggle
, EmailField
, Grid
, GridPro
, HtmlObject
, Input
, IntegerField
, MessageInput
, MultiSelectComboBox
, NativeButton
, NumberField
, PasswordField
, RangeInput
, RouterLink
, Scroller
, Select
, TextArea
, TextField
, TextFieldBase
, TimePicker
, TreeGrid
, VirtualList
Represents a component that can gain and lose focus.
Since:
1.0
Author:
Vaadin Ltd.
See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
BlurNotifier.BlurEvent<C extends Component>
Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
FocusNotifier.FocusEvent<C extends Component>
-
Method Summary
Modifier and TypeMethodDescriptiondefault ShortcutRegistration
addFocusShortcut
(Key key, KeyModifier... keyModifiers) default void
blur()
Calls the
blur
function at the client, making the component lose keyboard focus.default void
focus()
Calls the
focus
function at the client, making the component keyboard focused.default int
Gets the
tabindex
in the component.default void
setTabIndex
(int tabIndex) Sets the
tabindex
attribute in the component.Methods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListener
Methods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListener
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
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 beforetabindex = 5
, but aftertabindex = 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 attributeSee Also:
- A negative value (usually
-
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 anIllegalStateException
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 intSee 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
Adds a shortcut which focuses the
Component
which implementsFocusable
interface. The shortcut's event listener is in global scope and the shortcut's lifecycle is tied tothis
component.Use the returned
ShortcutRegistration
to fluently configure the shortcut.Parameters:
key
- primaryKey
used to trigger the shortcut. Cannot be null.keyModifiers
-KeyModifiers
that need to be pressed along with thekey
for the shortcut to triggerReturns:
ShortcutRegistration
for configuring the shortcut and removing
-