Skip to main content

TypedDropZone

Function TypedDropZone 

Source
pub fn TypedDropZone<T: DeserializeOwned + Clone + PartialEq + 'static>(
    _: TypedDropZoneProps<T>,
) -> Element
Expand description

A zone accepting typed drags (see typed) - JSON under typed::MIME decoded to T and delivered as a TypedDrop.

Handles the HTML5 boilerplate like ExternalDropZone: preventDefault on dragover, enter/leave depth counting, and data-over="true" while hovered. One honest limitation, spec-imposed: during hover the payload is unreadable (DataTransfer protected mode) and dioxus exposes no types list, so data-over lights for ANY drag hovering the zone - acceptance can only be judged at drop time. Drags with no typed entry at all are ignored silently at drop; drags whose JSON fails to decode as T fire on_invalid with the decode error.

ยงProps

For details, see the props struct definition.

  • on_drop : EventHandler<TypedDrop<T>>

    Fired with the decoded payload on a successful typed drop.

  • on_invalid : Option<EventHandler<String>>

    Fired when a drop carried a typed::MIME entry that failed to decode as T (the decode error, for diagnostics).

  • on_hover : Option<EventHandler<bool>>

    Fired with true/false on hover enter/leave.

  • attributes : Vec<Attribute>
  • children : Element