Class MouseEvents.ClickEvent

java.lang.Object
java.util.EventObject
com.vaadin.flow.component.ComponentEvent<com.vaadin.flow.component.Component>
com.vaadin.classic.v8.ui.Event
com.vaadin.classic.v8.event.MouseEvents.ClickEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
LayoutEvents.LayoutClickEvent
Enclosing interface:
MouseEvents

@DomEvent("mouseup") public static class MouseEvents.ClickEvent extends Event
Legacy MouseEvent class for holding information about a mouse click event. A MouseEvents.ClickEvent is fired when the user clicks on a Component. The information available for click events are terminal dependent. Correct values for all event details cannot be guaranteed.
Author:
Vaadin Ltd.
See Also:
  • Field Summary

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClickEvent(com.vaadin.flow.component.Component source, boolean fromClient, int clientX, int clientY, int clickCount, int button, boolean ctrlKey, boolean shiftKey, boolean altKey, boolean metaKey, int relativeX, int relativeY)
     
    ClickEvent(com.vaadin.flow.component.Component source, MouseEventDetails mouseEventDetails)
    Constructs a server-side ClickEvent with the given mouseEventDetails
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an identifier describing which mouse button the user pushed.
    Returns a human readable string representing which button has been pushed.
    int
    Returns the mouse position (x coordinate) when the click took place.
    int
    Returns the mouse position (y coordinate) when the click took place.
    com.vaadin.flow.component.Component
    Gets the component where the event occurred.
    Returns an information about mouse event like position, buttons pressed etc.
    int
    Returns the relative mouse position (x coordinate) when the click took place.
    int
    Returns the relative mouse position (y coordinate) when the click took place.
    boolean
    Checks if the Alt key was down when the mouse event took place.
    boolean
    Checks if the Ctrl key was down when the mouse event took place.
    boolean
    Checks if the event is a double click event.
    boolean
    Checks if the Meta key was down when the mouse event took place.
    boolean
    Checks if the Shift key was down when the mouse event took place.

    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(com.vaadin.flow.component.Component source, boolean fromClient, @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, @EventData("event.clientX - element.getBoundingClientRect().x") int relativeX, @EventData("event.clientY - element.getBoundingClientRect().y") int relativeY)
    • ClickEvent

      public ClickEvent(com.vaadin.flow.component.Component source, MouseEventDetails mouseEventDetails)
      Constructs a server-side ClickEvent with the given mouseEventDetails
  • Method Details

    • getComponent

      public com.vaadin.flow.component.Component getComponent()
      Gets the component where the event occurred.
      Overrides:
      getComponent in class Event
      Returns:
      the source component of the event
    • getButton

      public MouseEventDetails.MouseButton getButton()
      Returns an identifier describing which mouse button the user pushed. Compare with MouseEventDetails.MouseButton.LEFT,MouseEventDetails.MouseButton.MIDDLE, MouseEventDetails.MouseButton.RIGHT to find out which button it is.
      Returns:
      one of MouseEventDetails.MouseButton.LEFT, MouseEventDetails.MouseButton.MIDDLE, MouseEventDetails.MouseButton.RIGHT.
    • getClientX

      public int getClientX()
      Returns the mouse position (x coordinate) when the click took place. The position is relative to the browser client area.
      Returns:
      The mouse cursor x position
    • getClientY

      public int getClientY()
      Returns the mouse position (y coordinate) when the click took place. The position is relative to the browser client area.
      Returns:
      The mouse cursor y position
    • getRelativeX

      public int getRelativeX()
      Returns the relative mouse position (x coordinate) when the click took place. The position is relative to the clicked component.
      Returns:
      The mouse cursor x position relative to the clicked layout component or -1 if no x coordinate available
    • getRelativeY

      public int getRelativeY()
      Returns the relative mouse position (y coordinate) when the click took place. The position is relative to the clicked component.
      Returns:
      The mouse cursor y position relative to the clicked layout component or -1 if no y coordinate available
    • isDoubleClick

      public boolean isDoubleClick()
      Checks if the event is a double click event.
      Returns:
      true if the event is a double click event, false otherwise
    • isAltKey

      public boolean isAltKey()
      Checks if the Alt key was down when the mouse event took place.
      Returns:
      true if Alt was down when the event occurred, false otherwise
    • isCtrlKey

      public boolean isCtrlKey()
      Checks if the Ctrl key was down when the mouse event took place.
      Returns:
      true if Ctrl was pressed when the event occurred, false otherwise
    • isMetaKey

      public boolean isMetaKey()
      Checks if the Meta key was down when the mouse event took place.
      Returns:
      true if Meta was pressed when the event occurred, false otherwise
    • isShiftKey

      public boolean isShiftKey()
      Checks if the Shift key was down when the mouse event took place.
      Returns:
      true if Shift was pressed when the event occurred, false otherwise
    • getButtonName

      public String getButtonName()
      Returns a human readable string representing which button has been pushed. This is meant for debug purposes only and the string returned could change. Use getButton() to check which button was pressed.
      Returns:
      A string representation of which button was pushed.
    • getMouseEventDetails

      public MouseEventDetails getMouseEventDetails()
      Returns an information about mouse event like position, buttons pressed etc.
      Returns:
      An information about mouse event