pub struct DragTargetView<State: 'static, T: 'static> { /* private fields */ }Expand description
A declarative drop target. See the module docs.
Implementations§
Source§impl<State: 'static, T: 'static> DragTargetView<State, T>
impl<State: 'static, T: 'static> DragTargetView<State, T>
Sourcepub fn accepts<F: Fn(&T) -> bool + 'static>(self, f: F) -> Self
pub fn accepts<F: Fn(&T) -> bool + 'static>(self, f: F) -> Self
Only accept a payload f returns true for (default: accept every
T). A payload that fails this shows DragHighlight::Reject and is
never taken — see the module docs.
Sourcepub fn on_enter<F: Fn(&mut State) + 'static>(self, f: F) -> Self
pub fn on_enter<F: Fn(&mut State) + 'static>(self, f: F) -> Self
Run f against the app state when a session carrying a T first hovers
this target.
Sourcepub fn on_leave<F: Fn(&mut State) + 'static>(self, f: F) -> Self
pub fn on_leave<F: Fn(&mut State) + 'static>(self, f: F) -> Self
Run f against the app state when a hovering T session stops hovering
this target without dropping on it.
Sourcepub fn on_hover<F: Fn(&mut State, Point) + 'static>(self, f: F) -> Self
pub fn on_hover<F: Fn(&mut State, Point) + 'static>(self, f: F) -> Self
Run f against the app state, with the pointer converted to this
widget’s local space, on every distinct pointer position seen while a
T session hovers this target.
Sourcepub fn on_drop<F: Fn(&mut State, T) + 'static>(self, f: F) -> Self
pub fn on_drop<F: Fn(&mut State, T) + 'static>(self, f: F) -> Self
Run f against the app state with the dropped payload when an accepted
T session is released on this target.
Sourcepub fn highlight<F: Fn(&mut dyn PaintScene, Size, DragHighlight) + 'static>(
self,
f: F,
) -> Self
pub fn highlight<F: Fn(&mut dyn PaintScene, Size, DragHighlight) + 'static>( self, f: F, ) -> Self
Override the highlight paint seam (default: a 2px rounded inset stroke in the theme’s primary color). See the module docs.
Trait Implementations§
Source§impl<State: 'static, T: 'static> View<State> for DragTargetView<State, T>
impl<State: 'static, T: 'static> View<State> for DragTargetView<State, T>
Source§type Element = DragTargetWidget<State, T>
type Element = DragTargetWidget<State, T>
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> Self::Element
fn build(&self, ctx: &mut BuildCtx<'_>) -> Self::Element
Source§fn rebuild(
&self,
prev: &Self,
element: &mut Self::Element,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut Self::Element, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags
prev (the previous view of the same type) against the live
element, mutating it in place and reporting what changed.