pub struct MenuView<State: 'static> { /* private fields */ }Expand description
A declarative Material menu: a menu_panel inside the anchored host. See
menu.
The host is composed fresh in each pass from the props below rather than
retained: AnchoredOverlayView type-erases its content at construction,
so there is no way to reach back into the panel and re-set one of its own
props once it is inside.
Implementations§
Source§impl<State: 'static> MenuView<State>
impl<State: 'static> MenuView<State>
Sourcepub fn anchor(self, anchor: &OverlayAnchor) -> Self
pub fn anchor(self, anchor: &OverlayAnchor) -> Self
Anchor the menu to the rect anchor carries (see
crate::overlay::OverlayAnchor).
Sourcepub fn side(self, side: OverlaySide) -> Self
pub fn side(self, side: OverlaySide) -> Self
Set the side the menu opens on (bottom by default).
Sourcepub fn align(self, align: OverlayAlign) -> Self
pub fn align(self, align: OverlayAlign) -> Self
Set the cross-axis alignment (start by default, the reference’s
bottomStart).
Sourcepub fn offset(self, offset: f64) -> Self
pub fn offset(self, offset: f64) -> Self
Set the gap between trigger and menu (anchorOffset, 4dp by default).
Sourcepub fn color_style(self, style: MenuColorStyle) -> Self
pub fn color_style(self, style: MenuColorStyle) -> Self
Pick the standard or vibrant color resolution.
Sourcepub fn selected(self, value: Option<String>) -> Self
pub fn selected(self, value: Option<String>) -> Self
Hand the menu the app-confirmed selected value its
MenuSelectable rows check against.
Sourcepub fn open(self, open: bool) -> Self
pub fn open(self, open: bool) -> Self
Hand a kept-mounted menu the app’s open flag, so closing it plays the host’s exit ramp instead of vanishing — and closes the whole submenu cascade on the spot.
Sourcepub fn on_dismiss<F: Fn(&mut State) + 'static>(self, on_dismiss: F) -> Self
pub fn on_dismiss<F: Fn(&mut State) + 'static>(self, on_dismiss: F) -> Self
Set the dismiss callback: a press outside the menu, or Escape once the host holds focus.
Trait Implementations§
Source§impl<State: 'static> View<State> for MenuView<State>
impl<State: 'static> View<State> for MenuView<State>
Source§type Element = AnchoredOverlayWidget
type Element = AnchoredOverlayWidget
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> AnchoredOverlayWidget
fn build(&self, ctx: &mut BuildCtx<'_>) -> AnchoredOverlayWidget
Source§fn rebuild(
&self,
prev: &Self,
element: &mut AnchoredOverlayWidget,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut AnchoredOverlayWidget, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags
prev (the previous view of the same type) against the live
element, mutating it in place and reporting what changed.Auto Trait Implementations§
impl<State> !RefUnwindSafe for MenuView<State>
impl<State> !Send for MenuView<State>
impl<State> !Sync for MenuView<State>
impl<State> !UnwindSafe for MenuView<State>
impl<State> Freeze for MenuView<State>
impl<State> Unpin for MenuView<State>
impl<State> UnsafeUnpin for MenuView<State>where
Rc<dyn Fn(&mut State, MenuSelection)>: UnsafeUnpin,
Option<Rc<dyn Fn(&mut State)>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Source§impl<State, V> ViewSeq<State, One> for Vwhere
State: 'static,
V: View<State>,
impl<State, V> ViewSeq<State, One> for Vwhere
State: 'static,
V: View<State>,
Source§fn extend_views(self, out: &mut Vec<AnyView<State>>)
fn extend_views(self, out: &mut Vec<AnyView<State>>)
out — erasing each
with AnyView::new (a no-op for an element already an AnyView).