pub struct Menu<'a, T: 'a, S: AsMut<[MenuItem<'a, T>]>> { /* private fields */ }
Expand description
A (context) menu with nestable items
Implementations§
Source§impl<'a, T: 'a> Menu<'a, T, Vec<MenuItem<'a, T>>>
impl<'a, T: 'a> Menu<'a, T, Vec<MenuItem<'a, T>>>
Sourcepub fn position(self, (x, y): (f32, f32)) -> Self
pub fn position(self, (x, y): (f32, f32)) -> Self
Sets the (x, y) coordinates of the menu relative to it’s parent.
Sourcepub fn on_close(self, on_close: T) -> Self
pub fn on_close(self, on_close: T) -> Self
Sets the message to be posted when the menu is closed without selecting an item.
Sourcepub fn extend<I: IntoIterator<Item = MenuItem<'a, T>>>(self, iter: I) -> Self
pub fn extend<I: IntoIterator<Item = MenuItem<'a, T>>>(self, iter: I) -> Self
Adds items using an iterator
Trait Implementations§
Source§impl<'a, T: 'a + Send, S: 'a + Send + AsRef<[MenuItem<'a, T>]> + AsMut<[MenuItem<'a, T>]>> IntoNode<'a, T> for Menu<'a, T, S>
impl<'a, T: 'a + Send, S: 'a + Send + AsRef<[MenuItem<'a, T>]> + AsMut<[MenuItem<'a, T>]>> IntoNode<'a, T> for Menu<'a, T, S>
Source§impl<'a, T: 'a + Send, S: Send + AsRef<[MenuItem<'a, T>]> + AsMut<[MenuItem<'a, T>]>> Widget<'a, T> for Menu<'a, T, S>
impl<'a, T: 'a + Send, S: Send + AsRef<[MenuItem<'a, T>]> + AsMut<[MenuItem<'a, T>]>> Widget<'a, T> for Menu<'a, T, S>
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 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, _: &MenuState, style: &Stylesheet) -> (Size, Size)
fn size(&self, _: &MenuState, 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: &MenuState,
layout: Rectangle,
clip: Rectangle,
_style: &Stylesheet,
x: f32,
y: f32,
) -> bool
fn hit( &self, state: &MenuState, layout: Rectangle, clip: Rectangle, _style: &Stylesheet, x: f32, y: f32, ) -> bool
Source§fn focused(&self, state: &MenuState) -> bool
fn focused(&self, state: &MenuState) -> 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 MenuState,
viewport: Rectangle,
clip: Rectangle,
style: &Stylesheet,
event: Event,
context: &mut Context<T>,
)
fn event( &mut self, state: &mut MenuState, viewport: Rectangle, clip: Rectangle, style: &Stylesheet, event: Event, context: &mut Context<T>, )
Source§fn draw(
&mut self,
state: &mut MenuState,
viewport: Rectangle,
clip: Rectangle,
style: &Stylesheet,
) -> Vec<Primitive<'a>>
fn draw( &mut self, state: &mut MenuState, viewport: Rectangle, clip: Rectangle, style: &Stylesheet, ) -> Vec<Primitive<'a>>
Draw the widget. Returns a list of
Primitive
s that should be drawn. Read moreSource§fn state(&self, _state: &Self::State) -> StateVec
fn state(&self, _state: &Self::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 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, S> Freeze for Menu<'a, T, S>
impl<'a, T, S> RefUnwindSafe for Menu<'a, T, S>where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, S> Send for Menu<'a, T, S>
impl<'a, T, S> Sync for Menu<'a, T, S>
impl<'a, T, S> Unpin for Menu<'a, T, S>
impl<'a, T, S> UnwindSafe for Menu<'a, T, S>where
S: UnwindSafe,
T: UnwindSafe,
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