pub struct Drop<'a, T: DragDropId, Message, OnAccept, OnDrop> { /* private fields */ }
Expand description
A drop zone where draggable Drag
items may be dropped
Implementations§
Source§impl<'a, T: DragDropId, Message: 'a, OnAccept, OnDrop> Drop<'a, T, Message, OnAccept, OnDrop>
impl<'a, T: DragDropId, Message: 'a, OnAccept, OnDrop> Drop<'a, T, Message, OnAccept, OnDrop>
Sourcepub fn new(
context: &'a DragDropContext<T>,
accept: OnAccept,
drop: OnDrop,
content: impl IntoNode<'a, Message>,
) -> Self
pub fn new( context: &'a DragDropContext<T>, accept: OnAccept, drop: OnDrop, content: impl IntoNode<'a, Message>, ) -> Self
Construct a new Drop
widget
Sourcepub fn context(self, context: &'a DragDropContext<T>) -> Self
pub fn context(self, context: &'a DragDropContext<T>) -> Self
Sets the drag and drop context that the drop widget will work with.
Sourcepub fn on_accept<N: Fn(T) -> bool>(
self,
on_accept: N,
) -> Drop<'a, T, Message, N, OnDrop>
pub fn on_accept<N: Fn(T) -> bool>( self, on_accept: N, ) -> Drop<'a, T, Message, N, OnDrop>
Sets the on_accept delegate. If a draggable value is accepted by this drop target, the delegate should return true.
Sourcepub fn on_drop<N: Fn(T, (f32, f32)) -> Message>(
self,
on_drop: N,
) -> Drop<'a, T, Message, OnAccept, N>
pub fn on_drop<N: Fn(T, (f32, f32)) -> Message>( self, on_drop: N, ) -> Drop<'a, T, Message, OnAccept, N>
Sets the on_drop delegate. The delegate should return a message for it’s parent component based on the dropped value. The second argument contains the exact (x, y) coordinates where the value was dropped.
Sourcepub fn extend<I: IntoIterator<Item = N>, N: IntoNode<'a, Message>>(
self,
iter: I,
) -> Self
pub fn extend<I: IntoIterator<Item = N>, N: IntoNode<'a, Message>>( self, iter: I, ) -> Self
Sets the content widget from the first element of an iterator.
Trait Implementations§
Source§impl<'a, T: DragDropId, Message> Default for Drop<'a, T, Message, fn(T) -> bool, fn(T, (f32, f32)) -> Message>
impl<'a, T: DragDropId, Message> Default for Drop<'a, T, Message, fn(T) -> bool, fn(T, (f32, f32)) -> Message>
Source§impl<'a, T: DragDropId + Send + Sync, Message: 'a, OnAccept, OnDrop> IntoNode<'a, Message> for Drop<'a, T, Message, OnAccept, OnDrop>
impl<'a, T: DragDropId + Send + Sync, Message: 'a, OnAccept, OnDrop> IntoNode<'a, Message> for Drop<'a, T, Message, OnAccept, OnDrop>
Source§impl<'a, T, Message: 'a, OnAccept, OnDrop> Widget<'a, Message> for Drop<'a, T, Message, OnAccept, OnDrop>
impl<'a, T, Message: 'a, OnAccept, OnDrop> Widget<'a, Message> for Drop<'a, T, Message, OnAccept, OnDrop>
Source§fn widget(&self) -> &'static str
fn widget(&self) -> &'static str
The name of this widget, used to identify widgets of this type in stylesheets.
Source§fn state(&self, state: &DropState<T>) -> StateVec
fn state(&self, state: &DropState<T>) -> StateVec
The state of this widget, used for computing the style.
If
None
is returned, Node
will automatically compute a state, such as “hover” and “pressed”.Source§fn len(&self) -> usize
fn len(&self) -> usize
Should return the amount of children this widget has. Must be consistent with
visit_children()
.Source§fn visit_children(
&mut self,
visitor: &mut dyn FnMut(&mut dyn GenericNode<'a, Message>),
)
fn visit_children( &mut self, visitor: &mut dyn FnMut(&mut dyn GenericNode<'a, Message>), )
Source§fn size(&self, _: &DropState<T>, style: &Stylesheet) -> (Size, Size)
fn size(&self, _: &DropState<T>, style: &Stylesheet) -> (Size, Size)
Returns the
(width, height)
of this widget.
The extents are defined as a Size
,
which will later be resolved to actual dimensions.Source§fn event(
&mut self,
state: &mut DropState<T>,
layout: Rectangle,
clip: Rectangle,
style: &Stylesheet,
event: Event,
context: &mut Context<Message>,
)
fn event( &mut self, state: &mut DropState<T>, layout: Rectangle, clip: Rectangle, style: &Stylesheet, event: Event, context: &mut Context<Message>, )
Source§fn draw(
&mut self,
_: &mut DropState<T>,
layout: Rectangle,
clip: Rectangle,
style: &Stylesheet,
) -> Vec<Primitive<'a>>
fn draw( &mut self, _: &mut DropState<T>, layout: Rectangle, clip: Rectangle, style: &Stylesheet, ) -> Vec<Primitive<'a>>
Draw the widget. Returns a list of
Primitive
s that should be drawn. Read moreSource§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Returns whether this children has no children. Must be consistent with
visit_children()
.Source§fn hit(
&self,
_state: &Self::State,
layout: Rectangle,
clip: Rectangle,
_style: &Stylesheet,
x: f32,
y: f32,
) -> bool
fn hit( &self, _state: &Self::State, layout: Rectangle, clip: Rectangle, _style: &Stylesheet, x: f32, y: f32, ) -> bool
Source§fn focused(&self, _state: &Self::State) -> bool
fn focused(&self, _state: &Self::State) -> bool
Test the widget for focus exclusivity.
If the widget or one of it’s descendants is in an exclusive focus state, this function should return
true
.
In all other cases, it should return false
. When a widget is in an exclusive focus state it is
the only widget that is allowed to receive events in event
.
Widgets that intended to use this behaviour are modal dialogs, dropdown boxes, context menu’s, etc.Auto Trait Implementations§
impl<'a, T, Message, OnAccept, OnDrop> Freeze for Drop<'a, T, Message, OnAccept, OnDrop>
impl<'a, T, Message, OnAccept, OnDrop> !RefUnwindSafe for Drop<'a, T, Message, OnAccept, OnDrop>
impl<'a, T, Message, OnAccept, OnDrop> Send for Drop<'a, T, Message, OnAccept, OnDrop>
impl<'a, T, Message, OnAccept, OnDrop> !Sync for Drop<'a, T, Message, OnAccept, OnDrop>
impl<'a, T, Message, OnAccept, OnDrop> Unpin for Drop<'a, T, Message, OnAccept, OnDrop>
impl<'a, T, Message, OnAccept, OnDrop> !UnwindSafe for Drop<'a, T, Message, OnAccept, OnDrop>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more