Class AbstractDnDEvent<T extends com.vaadin.flow.component.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 com.vaadin.flow.component.Component> extends com.vaadin.flow.component.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.

Since:
25.1
Author:
Vaadin Ltd
See Also:
  • Field Summary

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractDnDEvent(T source, boolean fromClient, int clientX, int clientY)
    Creates a new drag and drop event.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the x coordinate of the mouse pointer relative to the viewport, excluding any scroll offset.
    int
    Gets the y coordinate of the mouse pointer relative to the viewport, excluding any scroll offset.
    Returns the component associated with this event.

    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

    • 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