Skip to content

DragTarget

Examples#

See these.

Inherits: Control

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.

Properties

Events

Properties#

content #

content: Control

The content of this control.

Must be visible.

Raises:

group #

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_accept #

on_accept: EventHandler[DragTargetEvent] | None = 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_leave #

on_leave: EventHandler[DragTargetLeaveEvent] | None = None

Called when a draggable leaves this target.

on_move #

on_move: EventHandler[DragTargetEvent] | None = None

Called when a draggable moves within this target.

on_will_accept #

on_will_accept: EventHandler[DragWillAcceptEvent] | None = (
    None
)

Called when a draggable is dragged on this target.