Expand description
DropZone — a “drop files here” target for external (OS) drag-and-drop.
A bordered, tinted region that accepts files / text / URLs dragged in from the operating system (Finder, Explorer, Nautilus) or another application. It reacts to hover (accept / reject highlight) and fires typed callbacks on drop. Because an OS drag cannot be initiated from the keyboard, the zone also offers a keyboard-operable Browse… button (opening the native file dialog) as the WCAG 2.1.1 equivalent.
DropZone::new(tr!("drop_images_here"))
.subtitle(tr!("png_or_jpeg"))
.accept_extensions(["png", "jpg", "jpeg"])
.allow_multiple(true)
.on_files_dropped(|paths, _ctx| { /* import paths */ });External drops are delivered through the framework’s normal drag pipeline
(on_drag_hover / on_drag_leave / on_drop) once
install_external_dnd is wired and a backend
is available. All four desktop backends are real (OLE on Windows,
NSDraggingDestination on macOS, wl_data_device on Wayland, XDND on X11
— see teksilo-platform/src/external_dnd.rs), so the Browse button is the
keyboard route rather than a fallback for a platform that cannot drop.
§Styling
The bordered, tinted chrome is a Tier-3 [DropZoneStyle]; the default
RecipeDropZoneStyle tracks the
interaction state. Override per-call with DropZone::style or theme-wide
via theme.style_slots.drop_zone.
§Accessibility
The zone is a Role::Group labelled by its prompt, with a Live::Polite
status line that announces hover (“Drop to add 3 files”), success
(“3 files added”), and rejection. AccessKit models no drag/drop action and
ARIA’s aria-grabbed / aria-dropeffect are deprecated, so live-region
announcements plus the Browse fallback are the supported pattern.
§Touch and pen
The zone is one target and the whole surface of it, so nothing here needs a floor or an outset, and an external drop carries no press to move to a release. The keyboard Browse fallback is what makes the action reachable at all where there is no OS drag-and-drop backend; it is not a touch affordance and is documented at its own builder.
Structs§
- Drop
Zone - A drop target for external (OS) drag-and-drop. See the module docs.