pub struct MenuItem { /* private fields */ }Expand description
An item in a Material menu. Callers retain command and selection state.
Implementations§
Source§impl MenuItem
impl MenuItem
pub fn new(id: impl Into<ElementId>, label: impl Into<SharedString>) -> MenuItem
pub fn group( id: impl Into<ElementId>, title: impl Into<SharedString>, ) -> MenuItem
Sourcepub fn divider(id: impl Into<ElementId>) -> MenuItem
pub fn divider(id: impl Into<ElementId>) -> MenuItem
Creates a non-interactive horizontal divider row inside a menu that is skipped by keyboard navigation.
Sourcepub fn section(
id: impl Into<ElementId>,
name: impl Into<SharedString>,
rows: impl IntoIterator<Item = MenuItem>,
) -> MenuItem
pub fn section( id: impl Into<ElementId>, name: impl Into<SharedString>, rows: impl IntoIterator<Item = MenuItem>, ) -> MenuItem
Creates a surfaced group with rows in the owning menu’s navigation order.
Sourcepub fn group_appearance(self, appearance: MenuSurfaceStyle) -> MenuItem
pub fn group_appearance(self, appearance: MenuSurfaceStyle) -> MenuItem
Sets the styled section’s surface appearance.
Sourcepub fn inactive_shape(self, shape: CornerShape) -> MenuItem
pub fn inactive_shape(self, shape: CornerShape) -> MenuItem
Sets the section shape used after the pointer leaves the section.
Sourcepub fn appearance(self, style: MenuItemStyle) -> MenuItem
pub fn appearance(self, style: MenuItemStyle) -> MenuItem
Configures the appearance of an action, checked or selected row.
Sourcepub fn tone(self, tone: SemanticTone) -> MenuItem
pub fn tone(self, tone: SemanticTone) -> MenuItem
Applies a Material 3 semantic tone to this row’s foreground and selected roles.
Explicit MenuItemStyle overrides and disabled styling still take precedence.
Sourcepub fn destructive(self) -> MenuItem
pub fn destructive(self) -> MenuItem
Shorthand for .tone(SemanticTone::Danger) on destructive menu commands.
Sourcepub fn shortcut(self, text: impl Into<SharedString>) -> MenuItem
pub fn shortcut(self, text: impl Into<SharedString>) -> MenuItem
Renders a desktop shortcut hint in the trailing slot using LabelSmall
and OnSurfaceVariant (or disabled color when disabled), unless an
explicit .trailing(...) overrides it.
pub fn disabled(self, disabled: bool) -> MenuItem
pub fn checked(self, checked: bool) -> MenuItem
pub fn selected(self, selected: bool) -> MenuItem
Sourcepub fn content<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
pub fn content<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
Replaces the visible label while retaining the name passed to new.
Supply a repeatable factory so the content also appears during exit.
Sourcepub fn leading<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
pub fn leading<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
Supplies a decorative element at the logical start of an unmarked row.
Sourcepub fn supporting<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
pub fn supporting<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
Supplies additional visual content below the label.
Sourcepub fn trailing<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
pub fn trailing<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
Supplies decorative content at the logical end of the row.
Sourcepub fn selection_icon<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
pub fn selection_icon<E>(self, build: impl Fn() -> E + 'static) -> MenuItemwhere
E: IntoElement,
Replaces the leading check mark of a checked or selected row.
Sourcepub fn on_checked_change(
self,
callback: impl Fn(bool, &mut Window, &mut App) + 'static,
) -> MenuItem
pub fn on_checked_change( self, callback: impl Fn(bool, &mut Window, &mut App) + 'static, ) -> MenuItem
Requests the inverse of the supplied checked value on activation.
The checked callback takes precedence over on_activate on checked rows.
pub fn on_activate( self, action: impl Fn(&mut Window, &mut App) + 'static, ) -> MenuItem
Auto Trait Implementations§
impl !RefUnwindSafe for MenuItem
impl !Send for MenuItem
impl !Sync for MenuItem
impl !UnwindSafe for MenuItem
impl Forget for MenuItem
impl Freeze for MenuItem
impl Move for MenuItem
impl Unpin for MenuItem
impl UnsafeUnpin for MenuItem
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
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> ⓘ
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> ⓘ
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> ⓘ
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