Skip to main content

DragTarget

Examples

See these.

A control that completes drag operation when a Draggable control is dropped.

When a Draggable is dragged on top of a DragTarget, the DragTarget is asked whether it will accept the data the Draggable is carrying. The DragTarget will accept incoming drag if it belongs to the same group as Draggable. If the user does drop the Draggable on top of the DragTarget (and the DragTarget has indicated that it will accept the Draggable's data), then the DragTarget is asked to accept the Draggable's data.

Inherits: Control

Properties

  • content - The content of this control.
  • group - The group this target belongs to.

Events

  • on_accept - Called when the user does drop an acceptable (same group) draggable on this target.
  • on_leave - Called when a draggable leaves this target.
  • on_move - Called when a draggable moves within this target.
  • on_will_accept - Called when a draggable is dragged on this target.

Properties

contentinstance-attribute

content: Annotated[Control, V.visible_control()]

The content of this control.

Raises:

  • ValueError - If it is not visible.

groupclass-attributeinstance-attribute

group: str = 'default'

The group this target belongs to.

Note

For a DragTarget to accept an incoming drop from a Draggable, they must both be in the same group.

Events

on_acceptclass-attributeinstance-attribute

on_accept: Optional[EventHandler[DragTargetEvent]] = None

Called when the user does drop an acceptable (same group) draggable on this target.

Use page.get_control(e.src_id) to retrieve Control reference by its ID.

on_leaveclass-attributeinstance-attribute

on_leave: Optional[EventHandler[DragTargetLeaveEvent]] = None

Called when a draggable leaves this target.

on_moveclass-attributeinstance-attribute

on_move: Optional[EventHandler[DragTargetEvent]] = None

Called when a draggable moves within this target.

on_will_acceptclass-attributeinstance-attribute

on_will_accept: Optional[EventHandler[DragWillAcceptEvent]] = None

Called when a draggable is dragged on this target.