Package 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
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:
-
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 ShortcutRegistrationaddFocusShortcut(Key key, KeyModifier... keyModifiers) default voidblur()Calls theblurfunction at the client, making the component lose keyboard focus.default voidfocus()Calls thefocusfunction at the client, making the component keyboard focused.default intGets thetabindexin the component.default voidsetTabIndex(int tabIndex) Sets thetabindexattribute in the component.Methods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
-
Method Details
-
setTabIndex
default void setTabIndex(int tabIndex) Sets thetabindexattribute 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 = -1means that the component should be focusable, but should not be reachable via sequential keyboard navigation. tabindex = 0means 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 = 4would 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 attribute- See Also:
- A negative value (usually
-
getTabIndex
default int getTabIndex()Gets thetabindexin 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 anIllegalStateExceptionis 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 thefocusfunction at the client, making the component keyboard focused.- See Also:
-
blur
default void blur()Calls theblurfunction at the client, making the component lose keyboard focus.- See Also:
-
addFocusShortcut
Adds a shortcut which focuses theComponentwhich implementsFocusableinterface. The shortcut's event listener is in global scope and the shortcut's lifecycle is tied tothiscomponent.Use the returned
ShortcutRegistrationto fluently configure the shortcut.- Parameters:
key- primaryKeyused to trigger the shortcut. Cannot be null.keyModifiers-KeyModifiersthat need to be pressed along with thekeyfor the shortcut to trigger- Returns:
ShortcutRegistrationfor configuring the shortcut and removing
-