pub struct MenuItem { /* private fields */ }Expand description
One entry of a DropdownMenu or a ContextMenu. It can run an
action, show a check mark, show any view, or open a submenu at its side.
use ravenrs_widgets::{DropdownMenu, MenuItem, Ui};
let menu = DropdownMenu::new("View")
.item(MenuItem::new("Show grid").checked(true))
.item(MenuItem::new("Export").item(MenuItem::new("As PDF")).item(MenuItem::new("As CSV")));
let mut ui = Ui::new(menu, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl MenuItem
impl MenuItem
Sourcepub fn shortcut(self, shortcut: impl Into<String>) -> MenuItem
pub fn shortcut(self, shortcut: impl Into<String>) -> MenuItem
Shows a shortcut hint at the trailing edge, e.g. "⌘C" (display only).
Sourcepub fn destructive(self) -> MenuItem
pub fn destructive(self) -> MenuItem
Paints the item in the danger color (Delete, Remove…).
Sourcepub fn on_select(self, handler: impl Fn() + 'static) -> MenuItem
pub fn on_select(self, handler: impl Fn() + 'static) -> MenuItem
Runs handler when the item is chosen; the menu closes first.
Sourcepub fn checked(self, checked: bool) -> MenuItem
pub fn checked(self, checked: bool) -> MenuItem
Makes it an item that is on or off: a check mark shows while it is on, and screen
readers hear which. What choosing it does is still up to Self::on_select.
Sourcepub fn element(self, view: impl View + 'static) -> MenuItem
pub fn element(self, view: impl View + 'static) -> MenuItem
Shows this view in the row instead of the label, such as a color with its name. The label still names the item for screen readers.
Sourcepub fn item(self, item: MenuItem) -> MenuItem
pub fn item(self, item: MenuItem) -> MenuItem
Adds an item to this item’s submenu, which opens at its side on hover, on click or
with the Right arrow; Left and Escape come back. An item with a submenu does not
run Self::on_select.