Skip to main content

on_insert

Function on_insert 

Source
pub fn on_insert(
    content: &ViewHandle,
    kinds: &[ContentType],
    action: impl Fn(i64, &[ItemProvider]) + 'static,
) -> ViewHandle
Expand description

.onInsert(of:perform:) — accept a drop into a ForEach’s rows.

A modifier on DynamicViewContent, not on View: the receiver has to be a ForEach, because what the action is told is where in the collection the drop landed. Handing it anything else fails loudly rather than rendering something that ignores drops — the conformance lookup is the check.

The action is (Int, [NSItemProvider]) -> Void: the index first, then what was dropped.