com.vaadin.flow.component.

Class ClickEvent<C extends Component>

    • Constructor Summary

      Constructors
      Constructor and Description
      ClickEvent(Component source)

      Creates a new server-side click event with no additional information.

      ClickEvent(Component source, boolean fromClient, int screenX, int screenY, int clientX, int clientY, int clickCount, int button, boolean ctrlKey, boolean shiftKey, boolean altKey, boolean metaKey)

      Creates a new click event.

    • Method Summary

      All Methods
      Modifier and Type Method and Description
      int getButton()

      Gets the id of the pressed mouse button.

      int getClickCount()

      Gets the number of consecutive clicks recently recorded.

      int getClientX()

      Gets the x coordinate of the click event, relative to the upper left corner of the browser viewport.

      int getClientY()

      Gets the y coordinate of the click event, relative to the upper left corner of the browser viewport.

      int getScreenX()

      Gets the x coordinate of the click event, relative to the upper left corner of the screen.

      int getScreenY()

      Gets the y coordinate of the click event, relative to the upper left corner of the screen.

      boolean isAltKey()

      Checks whether the alt key was was down when the event was fired.

      boolean isCtrlKey()

      Checks whether the ctrl key was was down when the event was fired.

      boolean isMetaKey()

      Checks whether the meta key was was down when the event was fired.

      boolean isShiftKey()

      Checks whether the shift key was was down when the event was fired.

    • Constructor Detail

      • ClickEvent

        public ClickEvent(Component source,
                          boolean fromClient,
                          @EventData(value="event.screenX")
                          int screenX,
                          @EventData(value="event.screenY")
                          int screenY,
                          @EventData(value="event.clientX")
                          int clientX,
                          @EventData(value="event.clientY")
                          int clientY,
                          @EventData(value="event.detail")
                          int clickCount,
                          @EventData(value="event.button")
                          int button,
                          @EventData(value="event.ctrlKey")
                          boolean ctrlKey,
                          @EventData(value="event.shiftKey")
                          boolean shiftKey,
                          @EventData(value="event.altKey")
                          boolean altKey,
                          @EventData(value="event.metaKey")
                          boolean metaKey)

        Creates a new click event.

        Parameters:

        source - the component that fired the event

        fromClient - true if the event was originally fired on the client, false if the event originates from server-side logic

        screenX - the x coordinate of the click event, relative to the upper left corner of the screen, -1 if unknown

        screenY - the y coordinate of the click event, relative to the upper left corner of the screen, -i if unknown

        clientX - the x coordinate of the click event, relative to the upper left corner of the browser viewport, -1 if unknown

        clientY - the y coordinate of the click event, relative to the upper left corner of the browser viewport, -1 if unknown

        clickCount - the number of consecutive clicks recently recorded

        button - the id of the pressed mouse button

        ctrlKey - true if the control key was down when the event was fired, false otherwise

        shiftKey - true if the shift key was down when the event was fired, false otherwise

        altKey - true if the alt key was down when the event was fired, false otherwise

        metaKey - true if the meta key was down when the event was fired, false otherwise

      • ClickEvent

        public ClickEvent(Component source)

        Creates a new server-side click event with no additional information.

        Parameters:

        source - the component that fired the event

    • Method Detail

      • getClientX

        public int getClientX()

        Gets the x coordinate of the click event, relative to the upper left corner of the browser viewport.

        Returns:

        the x coordinate, -1 if unknown

      • getClientY

        public int getClientY()

        Gets the y coordinate of the click event, relative to the upper left corner of the browser viewport.

        Returns:

        the y coordinate, -1 if unknown

      • getScreenX

        public int getScreenX()

        Gets the x coordinate of the click event, relative to the upper left corner of the screen.

        Returns:

        the x coordinate, -1 if unknown

      • getScreenY

        public int getScreenY()

        Gets the y coordinate of the click event, relative to the upper left corner of the screen.

        Returns:

        the y coordinate, -1 if unknown

      • getClickCount

        public int getClickCount()

        Gets the number of consecutive clicks recently recorded.

        Returns:

        the click count

      • getButton

        public int getButton()

        Gets the id of the pressed mouse button.

        • -1: No button
        • 0: The primary button, typically the left mouse button
        • 1: The middle button,
        • 2: The secondary button, typically the right mouse button
        • 3: The first additional button, typically the back button
        • 4: The second additional button, typically the forward button
        • 5+: More additional buttons without any typical meanings

        Returns:

        the button id, or -1 if no button was pressed

      • isCtrlKey

        public boolean isCtrlKey()

        Checks whether the ctrl key was was down when the event was fired.

        Returns:

        true if the ctrl key was down when the event was fired, false otherwise

      • isAltKey

        public boolean isAltKey()

        Checks whether the alt key was was down when the event was fired.

        Returns:

        true if the alt key was down when the event was fired, false otherwise

      • isMetaKey

        public boolean isMetaKey()

        Checks whether the meta key was was down when the event was fired.

        Returns:

        true if the meta key was down when the event was fired, false otherwise

      • isShiftKey

        public boolean isShiftKey()

        Checks whether the shift key was was down when the event was fired.

        Returns:

        true if the shift key was down when the event was fired, false otherwise