Package com.vaadin.flow.component
Interface ClickNotifier<T extends Component>
- Type Parameters:
T- the type of the component returned at theComponentEvent.getSource()
- All Superinterfaces:
Serializable
Mixin interface for components that support adding click listeners to the
their root elements.
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptiondefault RegistrationaddClickListener(ComponentEventListener<ClickEvent<T>> listener) Adds a click listener to this component.default ShortcutRegistrationaddClickShortcut(Key key, KeyModifier... keyModifiers) Adds a shortcut which 'clicks' theComponentwhich implementsClickNotifierinterface.default RegistrationaddDoubleClickListener(ComponentEventListener<ClickEvent<T>> listener) Adds a double click listener to this component.default RegistrationaddSingleClickListener(ComponentEventListener<ClickEvent<T>> listener) Adds a single click listener to this component.
-
Method Details
-
addClickListener
Adds a click listener to this component.- Parameters:
listener- the listener to add, notnull- Returns:
- a handle that can be used for removing the listener
-
addDoubleClickListener
Adds a double click listener to this component.- Parameters:
listener- the listener to add, notnull- Returns:
- a handle that can be used for removing the listener
-
addSingleClickListener
Adds a single click listener to this component.- Parameters:
listener- the listener to add, notnull- Returns:
- a handle that can be used for removing the listener
-
addClickShortcut
Adds a shortcut which 'clicks' theComponentwhich implementsClickNotifierinterface. 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.By default, the returned
ShortcutRegistrationallows browser's default behavior, unlike otherShortcutRegistrations. This is used to make sure that value synchronization of input fields is not blocked for the shortcut key (e.g. Enter key). To change this behavior, callShortcutRegistration.setBrowserDefaultAllowed(boolean).ShortcutRegistration.resetFocusOnActiveElement()resets focus on active element before triggering click event handler. It ensures that value synchronization of input fields with a ValueChangeMode.ON_CHANGE is done before click event handler is executed (e.g. when Enter key saves a form).- 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
-