pub struct Menu<R: Runtime>(/* private fields */);
desktop
only.Expand description
A type that is either a menu bar on the window on Windows and Linux or as a global menu in the menubar on macOS.
Implementations§
source§impl<R: Runtime> Menu<R>
impl<R: Runtime> Menu<R>
sourcepub fn with_id<M: Manager<R>, I: Into<MenuId>>(
manager: &M,
id: I
) -> Result<Self>
pub fn with_id<M: Manager<R>, I: Into<MenuId>>( manager: &M, id: I ) -> Result<Self>
Creates a new menu with the specified id.
sourcepub fn with_items<M: Manager<R>>(
manager: &M,
items: &[&dyn IsMenuItem<R>]
) -> Result<Self>
pub fn with_items<M: Manager<R>>( manager: &M, items: &[&dyn IsMenuItem<R>] ) -> Result<Self>
Creates a new menu with given items
. It calls Menu::new
and Menu::append_items
internally.
sourcepub fn with_id_and_items<M: Manager<R>, I: Into<MenuId>>(
manager: &M,
id: I,
items: &[&dyn IsMenuItem<R>]
) -> Result<Self>
pub fn with_id_and_items<M: Manager<R>, I: Into<MenuId>>( manager: &M, id: I, items: &[&dyn IsMenuItem<R>] ) -> Result<Self>
Creates a new menu with the specified id and given items
.
It calls Menu::new
and Menu::append_items
internally.
sourcepub fn default(app_handle: &AppHandle<R>) -> Result<Self>
pub fn default(app_handle: &AppHandle<R>) -> Result<Self>
Creates a menu filled with default menu items and submenus.
sourcepub fn app_handle(&self) -> &AppHandle<R>
pub fn app_handle(&self) -> &AppHandle<R>
The application handle associated with this type.
sourcepub fn append(&self, item: &dyn IsMenuItem<R>) -> Result<()>
pub fn append(&self, item: &dyn IsMenuItem<R>) -> Result<()>
sourcepub fn append_items(&self, items: &[&dyn IsMenuItem<R>]) -> Result<()>
pub fn append_items(&self, items: &[&dyn IsMenuItem<R>]) -> Result<()>
Add menu items to the end of this menu. It calls Menu::append
in a loop internally.
§Platform-specific:
- macOS: Only
Submenu
can be added to the menu
sourcepub fn prepend(&self, item: &dyn IsMenuItem<R>) -> Result<()>
pub fn prepend(&self, item: &dyn IsMenuItem<R>) -> Result<()>
sourcepub fn prepend_items(&self, items: &[&dyn IsMenuItem<R>]) -> Result<()>
pub fn prepend_items(&self, items: &[&dyn IsMenuItem<R>]) -> Result<()>
Add menu items to the beginning of this menu. It calls Menu::insert_items
with position of 0
internally.
§Platform-specific:
- macOS: Only
Submenu
can be added to the menu
sourcepub fn insert_items(
&self,
items: &[&dyn IsMenuItem<R>],
position: usize
) -> Result<()>
pub fn insert_items( &self, items: &[&dyn IsMenuItem<R>], position: usize ) -> Result<()>
sourcepub fn remove(&self, item: &dyn IsMenuItem<R>) -> Result<()>
pub fn remove(&self, item: &dyn IsMenuItem<R>) -> Result<()>
Remove a menu item from this menu.
sourcepub fn remove_at(&self, position: usize) -> Result<Option<MenuItemKind<R>>>
pub fn remove_at(&self, position: usize) -> Result<Option<MenuItemKind<R>>>
Remove the menu item at the specified position from this menu and returns it.
sourcepub fn get<'a, I>(&self, id: &'a I) -> Option<MenuItemKind<R>>
pub fn get<'a, I>(&self, id: &'a I) -> Option<MenuItemKind<R>>
Retrieves the menu item matching the given identifier.
sourcepub fn items(&self) -> Result<Vec<MenuItemKind<R>>>
pub fn items(&self) -> Result<Vec<MenuItemKind<R>>>
Returns a list of menu items that has been added to this menu.
Set this menu as the application menu.
This is an alias for AppHandle::set_menu
.
Set this menu as the window menu.
This is an alias for Window::set_menu
.