Class ClickEvent<C extends Component>

Type Parameters:
C - The source component type
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ItemClickEvent

@DomEvent("click") public class ClickEvent<C extends Component> extends ComponentEvent<C>
Event fired when a component is clicked.
Since:
1.0
Author:
Vaadin Ltd
See Also:
  • Field Summary

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Constructor
    Description
    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

    Modifier and Type
    Method
    Description
    int
    Gets the id of the pressed mouse button.
    int
    Gets the number of consecutive clicks recently recorded.
    int
    Gets the x coordinate of the click event, relative to the upper left corner of the browser viewport.
    int
    Gets the y coordinate of the click event, relative to the upper left corner of the browser viewport.
    int
    Gets the x coordinate of the click event, relative to the upper left corner of the screen.
    int
    Gets the y coordinate of the click event, relative to the upper left corner of the screen.
    boolean
    Checks whether the alt key was was down when the event was fired.
    boolean
    Checks whether the ctrl key was was down when the event was fired.
    boolean
    Checks whether the meta key was was down when the event was fired.
    boolean
    Checks whether the shift key was was down when the event was fired.

    Methods inherited from class com.vaadin.flow.component.ComponentEvent

    getSource, isFromClient, unregisterListener

    Methods inherited from class java.util.EventObject

    toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ClickEvent

      public ClickEvent(Component source, boolean fromClient, @EventData("event.screenX") int screenX, @EventData("event.screenY") int screenY, @EventData("event.clientX") int clientX, @EventData("event.clientY") int clientY, @EventData("event.detail") int clickCount, @EventData("event.button") int button, @EventData("event.ctrlKey") boolean ctrlKey, @EventData("event.shiftKey") boolean shiftKey, @EventData("event.altKey") boolean altKey, @EventData("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 Details

    • 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