Class AbstractDnDEvent<T extends Component>

java.lang.Object
java.util.EventObject
com.vaadin.flow.component.ComponentEvent<T>
com.vaadin.flow.component.dnd.AbstractDnDEvent<T>
Type Parameters:
T - Type of the component associated with the event.
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DragEndEvent, DragStartEvent, DropEvent

public abstract class AbstractDnDEvent<T extends Component> extends ComponentEvent<T>
Abstract base class for HTML5 drag and drop events.

In the browser, drag events inherit from MouseEvent, so this class provides access to common mouse event properties like cursor coordinates.

Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • AbstractDnDEvent

      protected AbstractDnDEvent(T source, boolean fromClient, int clientX, int clientY)
      Creates a new drag and drop event.
      Parameters:
      source - the component that is the source of the event
      fromClient - true if the event originated from the client side, false otherwise
      clientX - the x coordinate of the mouse pointer relative to the viewport, excluding any scroll offset
      clientY - the y coordinate of the mouse pointer relative to the viewport, excluding any scroll offset
  • Method Details

    • getClientX

      public int getClientX()
      Gets the x coordinate of the mouse pointer relative to the viewport, excluding any scroll offset.

      This is useful for positioning elements based on where the drag/drop operation occurred.

      Returns:
      the x coordinate relative to the viewport
    • getClientY

      public int getClientY()
      Gets the y coordinate of the mouse pointer relative to the viewport, excluding any scroll offset.

      This is useful for positioning elements based on where the drag/drop operation occurred.

      Returns:
      the y coordinate relative to the viewport
    • getComponent

      public T getComponent()
      Returns the component associated with this event.
      Returns:
      the component associated with this event