Interface ClickNotifier<T extends Component>

Type Parameters:
T - the type of the component returned at the ComponentEvent.getSource()
All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractIcon, Article, Aside, Button, Checkbox, DescriptionList, DescriptionList.Description, DescriptionList.Term, Div, DrawerToggle, Emphasis, FlexLayout, FontIcon, Footer, FormLayout, FormLayout.FormItem, H1, H2, H3, H4, H5, H6, Header, HorizontalLayout, HtmlObject, Icon, Image, ListItem, Main, MenuItem, NativeButton, NativeDetails, NativeDetails.Summary, Nav, OrderedList, Paragraph, Pre, Section, Span, SplitLayout, SvgIcon, UnorderedList, VerticalLayout

public interface ClickNotifier<T extends Component> extends Serializable
Mixin interface for components that support adding click listeners to the their root elements.
Since:
1.0
Author:
Vaadin Ltd
  • Method Details

    • addClickListener

      default Registration addClickListener(ComponentEventListener<ClickEvent<T>> listener)
      Adds a click listener to this component.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addDoubleClickListener

      default Registration addDoubleClickListener(ComponentEventListener<ClickEvent<T>> listener)
      Adds a double click listener to this component.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addSingleClickListener

      default Registration addSingleClickListener(ComponentEventListener<ClickEvent<T>> listener)
      Adds a single click listener to this component.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addClickShortcut

      default ShortcutRegistration addClickShortcut(Key key, KeyModifier... keyModifiers)
      Adds a shortcut which 'clicks' the Component which implements ClickNotifier 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.

      By default, the returned ShortcutRegistration allows browser's default behavior, unlike other ShortcutRegistrations. 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, call ShortcutRegistration.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 - 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