Struct Submenu
pub struct Submenu { /* private fields */ }Implementations§
pub fn new<S>(text: S, enabled: bool) -> Submenu
pub fn new<S>(text: S, enabled: bool) -> Submenu
Create a new submenu.
textcould optionally contain an&before a character to assign this character as the mnemonic for this submenu. To display a&without assigning a mnemenonic, use&&.
pub fn with_id<I, S>(id: I, text: S, enabled: bool) -> Submenu
pub fn with_id<I, S>(id: I, text: S, enabled: bool) -> Submenu
Create a new submenu with the specified id.
textcould optionally contain an&before a character to assign this character as the mnemonic for this submenu. To display a&without assigning a mnemenonic, use&&.
pub fn with_items<S>(
text: S,
enabled: bool,
items: &[&dyn IsMenuItem],
) -> Result<Submenu, Error>
pub fn with_items<S>( text: S, enabled: bool, items: &[&dyn IsMenuItem], ) -> Result<Submenu, Error>
Creates a new submenu with given items. It calls Submenu::new and Submenu::append_items internally.
pub fn with_id_and_items<I, S>(
id: I,
text: S,
enabled: bool,
items: &[&dyn IsMenuItem],
) -> Result<Submenu, Error>
pub fn with_id_and_items<I, S>( id: I, text: S, enabled: bool, items: &[&dyn IsMenuItem], ) -> Result<Submenu, Error>
Creates a new submenu with the specified id and given items. It calls Submenu::new and Submenu::append_items internally.
pub fn append(&self, item: &dyn IsMenuItem) -> Result<(), Error>
pub fn append(&self, item: &dyn IsMenuItem) -> Result<(), Error>
Add a menu item to the end of this menu.
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 submenu. It calls Submenu::append in a loop.
pub fn prepend(&self, item: &dyn IsMenuItem) -> Result<(), Error>
pub fn prepend(&self, item: &dyn IsMenuItem) -> Result<(), Error>
Add a menu item to the beginning of this submenu.
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 submenu.
It calls Menu::prepend on the first element and
passes the rest to Menu::insert_items with position of 1.
pub fn insert(
&self,
item: &dyn IsMenuItem,
position: usize,
) -> Result<(), Error>
pub fn insert( &self, item: &dyn IsMenuItem, position: usize, ) -> Result<(), Error>
Insert a menu item at the specified postion in the submenu.
pub fn insert_items(
&self,
items: &[&dyn IsMenuItem],
position: usize,
) -> Result<(), Error>
pub fn insert_items( &self, items: &[&dyn IsMenuItem], position: usize, ) -> Result<(), Error>
Insert menu items at the specified postion in the submenu.
pub fn remove(&self, item: &dyn IsMenuItem) -> Result<(), Error>
pub fn remove(&self, item: &dyn IsMenuItem) -> Result<(), Error>
Remove a menu item from this submenu.
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 submenu 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 submenu.
pub fn set_text<S>(&self, text: S)
pub fn set_text<S>(&self, text: S)
Set the text for this submenu. text could optionally contain
an & before a character to assign this character as the mnemonic
for this submenu. To display a & without assigning a mnemenonic, use &&.
pub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Get whether this submenu is enabled or not.
pub fn set_enabled(&self, enabled: bool)
pub fn set_enabled(&self, enabled: bool)
Enable or disable this submenu.
Set this submenu as the Window menu for the application on macOS. This will cause macOS to automatically add window-switching items and certain other items to the menu.
Must be called after adding this submenu to Menu
and after calling Menu::init_for_nsapp on that menu.
§Note
Because a Submenu can be added multiple times to the same Menu
this method will set the first instance of this submenu as the Window menu for the application.
It is not recommended to add the same submenu multiple times to the same menu, but if you do, be aware of this behavior.
Set this submenu as the Help menu for the application on macOS. This will cause macOS to automatically add a search box to the menu.
Must be called after adding this submenu to Menu
and after calling Menu::init_for_nsapp on that menu.
If no menu is set as the Help menu, macOS will automatically use any menu which has a title matching the localized word “Help”.
§Note
Because a Submenu can be added multiple times to the same Menu
this method will set the first instance of this submenu as the Help menu for the application.
It is not recommended to add the same submenu multiple times to the same menu, but if you do, be aware of this behavior.
pub fn set_native_icon(&self, _icon: Option<NativeIcon>)
pub fn set_native_icon(&self, _icon: Option<NativeIcon>)
Change this menu item icon to a native image or remove it.
§Platform-specific:
- Windows / Linux: Unsupported.
Trait Implementations§
NSView. Read moreSubmenu, and returns None if it wasn’t.Menu, and returns None if it wasn’t.Menu, and panics if it wasn’t.Submenu, and panics if it wasn’t.§fn kind(&self) -> MenuItemKind
fn kind(&self) -> MenuItemKind
MenuItemKind associated with this item.Auto Trait Implementations§
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
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>
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>
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