Skip to main content

DragTarget

Struct DragTarget 

Source
pub struct DragTarget<T: 'static> {
    pub key: Option<KeyRef>,
    pub builder: DragTargetBuilder<T>,
    pub on_will_accept: Option<DragTargetWillAccept<T>>,
    pub on_will_accept_with_details: Option<DragTargetWillAcceptWithDetails<T>>,
    pub on_accept: Option<DragTargetAccept<T>>,
    pub on_accept_with_details: Option<DragTargetAcceptWithDetails<T>>,
    pub on_leave: Option<DragTargetLeave<T>>,
    pub on_move: Option<DragTargetMove<T>>,
    pub hit_test_behavior: HitTestBehavior,
}
Expand description

A widget that receives data when a Draggable is dropped over it.

Fields§

§key: Option<KeyRef>

Identity of this target in its parent’s child list.

§builder: DragTargetBuilder<T>

Builds the target using all current accepted and rejected drag data.

§on_will_accept: Option<DragTargetWillAccept<T>>

Legacy data-only acceptance predicate; mutually exclusive with the detailed predicate.

§on_will_accept_with_details: Option<DragTargetWillAcceptWithDetails<T>>

Determines whether to accept an entering drag, including its position.

§on_accept: Option<DragTargetAccept<T>>

Called when non-null data is dropped on this target.

§on_accept_with_details: Option<DragTargetAcceptWithDetails<T>>

Called when non-null data is dropped, including its position.

§on_leave: Option<DragTargetLeave<T>>

Called when a drag leaves this target.

§on_move: Option<DragTargetMove<T>>

Called when non-null drag data moves within this target.

§hit_test_behavior: HitTestBehavior

Defaults to translucent so targets behind rejected targets can receive a drag.

Implementations§

Source§

impl<T: 'static> DragTarget<T>

Source

pub fn new( builder: impl Fn(&mut App, BuildContext, Vec<Option<Rc<T>>>, Vec<Option<Rc<dyn Any>>>) -> WidgetRef + 'static, ) -> Self

Creates a target whose presentation reflects the current candidate and rejected data.

Source

pub fn key(self, value: KeyRef) -> Self

Sets the widget identity.

Source

pub fn on_will_accept(self, value: DragTargetWillAccept<T>) -> Self

Sets the legacy data-only acceptance predicate.

Source

pub fn on_will_accept_with_details( self, value: DragTargetWillAcceptWithDetails<T>, ) -> Self

Sets the predicate for accepting an entering drag.

Source

pub fn on_accept(self, value: DragTargetAccept<T>) -> Self

Sets the callback for dropped non-null data.

Source

pub fn on_accept_with_details( self, value: DragTargetAcceptWithDetails<T>, ) -> Self

Sets the callback for a drop’s data and global position.

Source

pub fn on_leave(self, value: DragTargetLeave<T>) -> Self

Sets the callback for a drag leaving the target.

Source

pub fn on_move(self, value: DragTargetMove<T>) -> Self

Sets the callback for movement within the target.

Source

pub fn hit_test_behavior(self, value: HitTestBehavior) -> Self

Sets how the target participates in hit testing.

Trait Implementations§

Source§

impl<T: 'static> Debug for DragTarget<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: 'static> StatefulWidget for DragTarget<T>

Source§

type State = DragTargetState<T>

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn create_state(&self) -> Self::State

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s debugFillProperties: the properties a dump shows for this widget, in Dart’s order. Dart’s Widget base only sets the dense tree style, which the framework does.
Source§

fn debug_check_constructor(&self)

Source§

fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>

Source§

fn type_name(&self) -> &'static str

See Widget::type_name. A stateful form another widget kind becomes (an animated or status transition widget) names the widget it wraps.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for DragTarget<T>

§

impl<T> !Send for DragTarget<T>

§

impl<T> !Sync for DragTarget<T>

§

impl<T> !UnwindSafe for DragTarget<T>

§

impl<T> Forget for DragTarget<T>

§

impl<T> Freeze for DragTarget<T>
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, Vec<Option<Rc<T>>>, Vec<Option<Rc<dyn Any>>>) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Vec<Option<Rc<T>>>, Vec<Option<Rc<dyn Any>>>) -> Rc<dyn Widget>>>: Freeze, *const RcInner<dyn Fn(&mut App, Option<Rc<T>>) -> bool> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, Option<Rc<T>>) -> bool>>: Freeze, *const RcInner<dyn Fn(&mut App, DragTargetDetails<T>) -> bool> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, DragTargetDetails<T>) -> bool>>: Freeze, *const RcInner<dyn Fn(&mut App, Rc<T>)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, Rc<T>)>>: Freeze, *const RcInner<dyn Fn(&mut App, DragTargetDetails<T>)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, DragTargetDetails<T>)>>: Freeze, *const RcInner<dyn Fn(&mut App, Option<Rc<T>>)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, Option<Rc<T>>)>>: Freeze,

§

impl<T> Move for DragTarget<T>

§

impl<T> Unpin for DragTarget<T>
where Rc<dyn Key>: Unpin, Rc<dyn Fn(&mut App, AnyElement, Vec<Option<Rc<T>>>, Vec<Option<Rc<dyn Any>>>) -> Rc<dyn Widget>>: Unpin, Rc<dyn Fn(&mut App, Option<Rc<T>>) -> bool>: Unpin, Rc<dyn Fn(&mut App, DragTargetDetails<T>) -> bool>: Unpin, Rc<dyn Fn(&mut App, Rc<T>)>: Unpin, Rc<dyn Fn(&mut App, DragTargetDetails<T>)>: Unpin, Rc<dyn Fn(&mut App, Option<Rc<T>>)>: Unpin,

§

impl<T> UnsafeUnpin for DragTarget<T>
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, Vec<Option<Rc<T>>>, Vec<Option<Rc<dyn Any>>>) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Vec<Option<Rc<T>>>, Vec<Option<Rc<dyn Any>>>) -> Rc<dyn Widget>>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, Option<Rc<T>>) -> bool> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, Option<Rc<T>>) -> bool>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, DragTargetDetails<T>) -> bool> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, DragTargetDetails<T>) -> bool>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, Rc<T>)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, Rc<T>)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, DragTargetDetails<T>)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, DragTargetDetails<T>)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, Option<Rc<T>>)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, Option<Rc<T>>)>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>