pub struct MenuItem { /* private fields */ }Expand description
A single selectable row inside a Menu.
Add with ui.add(MenuItem::new("…")) inside a menu body. The returned
Response’s .clicked() fires on activation.
The optional icon, checked, and
radio builders all reserve the same leading gutter,
so toggle items in a menu align cleanly with action items as long as
every item in that menu opts into one of them.
Implementations§
Source§impl MenuItem
impl MenuItem
Sourcepub fn new(label: impl Into<WidgetText>) -> Self
pub fn new(label: impl Into<WidgetText>) -> Self
Create a menu item with the given label.
Sourcepub fn shortcut(self, shortcut: impl Into<String>) -> Self
pub fn shortcut(self, shortcut: impl Into<String>) -> Self
Display a keyboard-shortcut hint on the right (informational only — the actual shortcut is not bound).
Sourcepub fn danger(self) -> Self
pub fn danger(self) -> Self
Render the item in the danger tone — red label, red hover highlight. Use for destructive actions.
Sourcepub fn enabled(self, enabled: bool) -> Self
pub fn enabled(self, enabled: bool) -> Self
Disable the item. Disabled items do not fire clicked() and render
with muted text.
Sourcepub fn icon(self, icon: impl Into<WidgetText>) -> Self
pub fn icon(self, icon: impl Into<WidgetText>) -> Self
Show a leading icon (any text, typically a unicode glyph) in the gutter to the left of the label. Reserves the gutter even when the glyph is narrow, so adjacent items align.