Struct Menu
pub struct Menu { /* private fields */ }Available on crate feature
tray only.Expand description
A root menu that can be added to a Window on Windows and Linux and used as the app global menu on macOS.
Implementations§
§impl Menu
impl Menu
pub fn with_items(items: &[&dyn IsMenuItem]) -> Result<Menu, Error>
pub fn with_items(items: &[&dyn IsMenuItem]) -> Result<Menu, Error>
Creates a new menu with given items. It calls Menu::new and Menu::append_items internally.
pub fn with_id_and_items<I>(
id: I,
items: &[&dyn IsMenuItem],
) -> Result<Menu, Error>
pub fn with_id_and_items<I>( id: I, items: &[&dyn IsMenuItem], ) -> Result<Menu, Error>
Creates a new menu with the specified id and given items. It calls Menu::new and Menu::append_items internally.
pub fn append(&self, item: &dyn IsMenuItem) -> Result<(), Error>
pub fn append(&self, item: &dyn IsMenuItem) -> Result<(), Error>
pub fn append_items(&self, items: &[&dyn IsMenuItem]) -> Result<(), Error>
pub fn append_items(&self, items: &[&dyn IsMenuItem]) -> Result<(), Error>
Add menu items to the end of this menu. It calls Menu::append in a loop internally.
§Platform-spcific:
- macOS: Only
Submenucan be added to the menu
pub fn prepend(&self, item: &dyn IsMenuItem) -> Result<(), Error>
pub fn prepend(&self, item: &dyn IsMenuItem) -> Result<(), Error>
pub fn prepend_items(&self, items: &[&dyn IsMenuItem]) -> Result<(), Error>
pub fn prepend_items(&self, items: &[&dyn IsMenuItem]) -> Result<(), Error>
Add menu items to the beginning of this menu. It calls Menu::insert_items with position of 0 internally.
§Platform-spcific:
- macOS: Only
Submenucan be added to the menu
pub fn insert_items(
&self,
items: &[&dyn IsMenuItem],
position: usize,
) -> Result<(), Error>
pub fn insert_items( &self, items: &[&dyn IsMenuItem], position: usize, ) -> Result<(), Error>
pub fn remove(&self, item: &dyn IsMenuItem) -> Result<(), Error>
pub fn remove(&self, item: &dyn IsMenuItem) -> Result<(), Error>
Remove a menu item from this menu.
pub fn remove_at(&self, position: usize) -> Option<MenuItemKind>
pub fn remove_at(&self, position: usize) -> Option<MenuItemKind>
Remove the menu item at the specified position from this menu and returns it.
pub fn items(&self) -> Vec<MenuItemKind>
pub fn items(&self) -> Vec<MenuItemKind>
Returns a list of menu items that has been added to this menu.
pub fn init_for_nsapp(&self)
pub fn init_for_nsapp(&self)
Adds this menu to an NSApp.
pub fn remove_for_nsapp(&self)
pub fn remove_for_nsapp(&self)
Removes this menu from an NSApp.
Trait Implementations§
§impl ContextMenu for Menu
impl ContextMenu for Menu
Shows this menu as a context menu for the specified
NSView. Read moreGet the underlying NSMenu reserved for context menus. Read more
Cast this context menu to a
Menu, and returns None if it wasn’t.Casts this context menu to a
Menu, and panics if it wasn’t.Cast this context menu to a
Submenu, and returns None if it wasn’t.Casts this context menu to a
Submenu, and panics if it wasn’t.Auto Trait Implementations§
impl Freeze for Menu
impl !RefUnwindSafe for Menu
impl !Send for Menu
impl !Sync for Menu
impl Unpin for Menu
impl !UnwindSafe for Menu
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().