pub struct Dropdown<'a, T, F> { /* private fields */ }
Expand description
Pick an item from a dropdown box
Implementations§
Source§impl<'a, T: 'a, F> Dropdown<'a, T, F>
impl<'a, T: 'a, F> Dropdown<'a, T, F>
Sourcepub fn default_selection(self, item_index: usize) -> Self
pub fn default_selection(self, item_index: usize) -> Self
Set the default selected item
Sourcepub fn on_select<N: Fn(usize) -> T>(self, on_select: N) -> Dropdown<'a, T, N>
pub fn on_select<N: Fn(usize) -> T>(self, on_select: N) -> Dropdown<'a, T, N>
Sets the on_select callback for the dropdown, which is called when an item is selected
Sourcepub fn extend(
self,
items: impl IntoIterator<Item = impl IntoNode<'a, T>>,
) -> Self
pub fn extend( self, items: impl IntoIterator<Item = impl IntoNode<'a, T>>, ) -> Self
Add multiple items to the dropdown.
Trait Implementations§
Source§impl<'a, T: 'a + Send, F: 'a + Send + Fn(usize) -> T> IntoNode<'a, T> for Dropdown<'a, T, F>
impl<'a, T: 'a + Send, F: 'a + Send + Fn(usize) -> T> IntoNode<'a, T> for Dropdown<'a, T, F>
Source§impl<'a, T: Send + 'a, F: Send + Fn(usize) -> T> Widget<'a, T> for Dropdown<'a, T, F>
impl<'a, T: Send + 'a, F: Send + Fn(usize) -> T> Widget<'a, T> for Dropdown<'a, T, F>
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: &State) -> StateVec
fn state(&self, state: &State) -> 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, T>),
)
fn visit_children( &mut self, visitor: &mut dyn FnMut(&mut dyn GenericNode<'a, T>), )
Source§fn size(&self, _: &State, style: &Stylesheet) -> (Size, Size)
fn size(&self, _: &State, 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 hit(
&self,
state: &State,
layout: Rectangle,
clip: Rectangle,
_: &Stylesheet,
x: f32,
y: f32,
) -> bool
fn hit( &self, state: &State, layout: Rectangle, clip: Rectangle, _: &Stylesheet, x: f32, y: f32, ) -> bool
Source§fn focused(&self, state: &State) -> bool
fn focused(&self, state: &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.Source§fn event(
&mut self,
state: &mut State,
layout: Rectangle,
clip: Rectangle,
_: &Stylesheet,
event: Event,
context: &mut Context<T>,
)
fn event( &mut self, state: &mut State, layout: Rectangle, clip: Rectangle, _: &Stylesheet, event: Event, context: &mut Context<T>, )
Source§fn draw(
&mut self,
state: &mut State,
layout: Rectangle,
clip: Rectangle,
style: &Stylesheet,
) -> Vec<Primitive<'a>>
fn draw( &mut self, state: &mut State, 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()
.Auto Trait Implementations§
impl<'a, T, F> Freeze for Dropdown<'a, T, F>where
F: Freeze,
impl<'a, T, F> !RefUnwindSafe for Dropdown<'a, T, F>
impl<'a, T, F> Send for Dropdown<'a, T, F>where
F: Send,
impl<'a, T, F> !Sync for Dropdown<'a, T, F>
impl<'a, T, F> Unpin for Dropdown<'a, T, F>where
F: Unpin,
impl<'a, T, F> !UnwindSafe for Dropdown<'a, T, F>
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