pub struct DndContext<T: Clone + 'static> { /* private fields */ }Expand description
Handle to the shared drag state. Cheap to copy - it’s just a store key.
Implementations§
Source§impl<T: Clone + 'static> DndContext<T>
impl<T: Clone + 'static> DndContext<T>
Sourcepub fn from_parts(
state: Store<DragState<T>>,
announcement: Signal<String>,
) -> Self
pub fn from_parts( state: Store<DragState<T>>, announcement: Signal<String>, ) -> Self
Wrap existing state. Prefer crate::core::hooks::use_dnd_provider.
Sourcepub fn start(
&mut self,
payload: T,
source: Option<ZoneId>,
pointer: Point,
grab: Point,
effect: DropEffect,
mode: DragMode,
)
pub fn start( &mut self, payload: T, source: Option<ZoneId>, pointer: Point, grab: Point, effect: DropEffect, mode: DragMode, )
Begin a drag. Notifies all fields (state transition).
Sourcepub fn update_pointer(&mut self, pointer: Point)
pub fn update_pointer(&mut self, pointer: Point)
Update the tracked pointer position (drives DragOverlay). Granular:
only pointer subscribers rerun.
Sourcepub fn enter(&mut self, zone: ZoneId)
pub fn enter(&mut self, zone: ZoneId)
Mark zone as hovered. Granular: only over subscribers rerun.
Sourcepub fn leave(&mut self, zone: ZoneId)
pub fn leave(&mut self, zone: ZoneId)
Clear hover, but only if zone is still the hovered one (avoids
enter/leave races between adjacent zones).
Sourcepub fn take(&mut self) -> Option<(T, Option<ZoneId>)>
pub fn take(&mut self) -> Option<(T, Option<ZoneId>)>
Consume the payload on a successful drop. Returns (payload, source).
After this, dragging() is false.
Sourcepub fn effect(&self) -> DropEffect
pub fn effect(&self) -> DropEffect
Effect the drag was started with.
Sourcepub fn announce(&mut self, msg: impl Into<String>)
pub fn announce(&mut self, msg: impl Into<String>)
Push a screen-reader announcement (rendered by
crate::a11y::LiveRegion). Called automatically by the built-in
keyboard interaction; call it yourself for custom flows.
Sourcepub fn announcement(&self) -> String
pub fn announcement(&self) -> String
The current announcement text.