pub struct MaterialMenu { /* private fields */ }Expand description
An M3 menu surface. Use MenuPopup to open it from a trigger.
Implementations§
Source§impl MaterialMenu
impl MaterialMenu
pub fn new(id: impl Into<ElementId>) -> Self
pub fn style(self, style: MenuStyle) -> Self
Sourcepub fn density(self, density: MenuDensity) -> Self
pub fn density(self, density: MenuDensity) -> Self
Item density: the kit’s baseline densities, and half those steps for Expressive items.
Sourcepub fn item(self, item: MaterialMenuItem) -> Self
pub fn item(self, item: MaterialMenuItem) -> Self
Append an item to the last group.
pub fn items(self, items: impl IntoIterator<Item = MaterialMenuItem>) -> Self
pub fn group(self, group: MenuGroup) -> Self
Sourcepub fn width(self, width: f32) -> Self
pub fn width(self, width: f32) -> Self
Width in design px (default 200 baseline, 208 Expressive).
Sourcepub fn elevated(self, elevated: bool) -> Self
pub fn elevated(self, elevated: bool) -> Self
Paint the menu’s level 2 shadow (default). A popup paints it on its revealing frame instead.
Sourcepub fn track_focus(self, focus: &FocusHandle) -> Self
pub fn track_focus(self, focus: &FocusHandle) -> Self
The handle the menu root tracks; arrow keys from it reach the items.
Sourcepub fn on_dismiss(
self,
handler: impl Fn(&mut Window, &mut App) + 'static,
) -> Self
pub fn on_dismiss( self, handler: impl Fn(&mut Window, &mut App) + 'static, ) -> Self
Escape inside the menu.
Sourcepub fn on_activate(
self,
handler: impl Fn(&mut Window, &mut App) + 'static,
) -> Self
pub fn on_activate( self, handler: impl Fn(&mut Window, &mut App) + 'static, ) -> Self
Runs after any enabled item (other than a sub-menu) is activated.
Sourcepub fn on_collapse(
self,
handler: impl Fn(&mut Window, &mut App) + 'static,
) -> Self
pub fn on_collapse( self, handler: impl Fn(&mut Window, &mut App) + 'static, ) -> Self
Left inside the menu, e.g. to close it as a cascading sub-menu.
Sourcepub fn natural_height(&self) -> f32
pub fn natural_height(&self) -> f32
The menu’s natural height in design px.
Sourcepub fn item_bottom(&self, index: usize) -> Option<f32>
pub fn item_bottom(&self, index: usize) -> Option<f32>
The bottom of the item at flat index (its row without a divider
below it), in design px from the menu’s top.
Trait Implementations§
Source§impl IntoElement for MaterialMenu
impl IntoElement for MaterialMenu
Source§type Element = ViewElement<MaterialMenu>
type Element = ViewElement<MaterialMenu>
The specific type of element into which the implementing type is converted.
Useful for converting other types into elements automatically, like Strings
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Convert self into a type that implements [
Element].Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
Convert self into a dynamically-typed [
AnyElement].Auto Trait Implementations§
impl !RefUnwindSafe for MaterialMenu
impl !Send for MaterialMenu
impl !Sync for MaterialMenu
impl !UnwindSafe for MaterialMenu
impl Freeze for MaterialMenu
impl Unpin for MaterialMenu
impl UnsafeUnpin for MaterialMenu
Blanket Implementations§
§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Render this component or element with an animation
§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Render this component or element with a chain of animations
§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>where
Self: Sized,
T: SpringTarget,
<T as SpringTarget>::Output: 'static,
fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>where
Self: Sized,
T: SpringTarget,
<T as SpringTarget>::Output: 'static,
Renders this component or element at the value produced by a spring. Read more
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Imperatively modify self with the given closure.
§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Conditionally modify self with the given closure.
§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Conditionally modify self with the given closure.
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
§fn test_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_text(self, text: impl Into<SharedString>) -> Self::Element
With
test-support, records text each time the element paints.
Otherwise returns the element it builds.§fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
Like [
Self::test_text] for an image’s alternative text, which
stands in for what the element draws.