Struct tauri_runtime::menu::Menu
source · #[non_exhaustive]pub struct Menu {
pub items: Vec<MenuEntry>,
}
Expand description
A window menu.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.items: Vec<MenuEntry>
Implementations§
source§impl Menu
impl Menu
sourcepub fn os_default(app_name: &str) -> Self
pub fn os_default(app_name: &str) -> Self
Creates a menu filled with default menu items and submenus.
Platform-specific:
-
Windows:
- File
- CloseWindow
- Quit
- Edit
- Cut
- Copy
- Paste
- Window
- Minimize
- CloseWindow
- File
-
Linux:
- File
- CloseWindow
- Quit
- Window
- Minimize
- CloseWindow
- File
-
macOS:
- App
- About
- Separator
- Services
- Separator
- Hide
- HideOthers
- ShowAll
- Separator
- Quit
- File
- CloseWindow
- Edit
- Undo
- Redo
- Separator
- Cut
- Copy
- Paste
- SelectAll
- View
- EnterFullScreen
- Window
- Minimize
- Zoom
- Separator
- CloseWindow
- App
sourcepub fn with_items<I: IntoIterator<Item = MenuEntry>>(items: I) -> Self
pub fn with_items<I: IntoIterator<Item = MenuEntry>>(items: I) -> Self
Creates a new window menu with the given items.
Examples
Menu::with_items([
MenuItem::SelectAll.into(),
#[cfg(target_os = "macos")]
MenuItem::Redo.into(),
CustomMenuItem::new("toggle", "Toggle visibility").into(),
Submenu::new("View", Menu::new()).into(),
]);
sourcepub fn add_item(self, item: CustomMenuItem) -> Self
pub fn add_item(self, item: CustomMenuItem) -> Self
Adds the custom menu item to the menu.
sourcepub fn add_native_item(self, item: MenuItem) -> Self
pub fn add_native_item(self, item: MenuItem) -> Self
Adds a native item to the menu.
Adds an entry with submenu.