Struct Submenu
pub struct Submenu { /* private fields */ }tray only.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.
Available on macOS only.
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.
Available on macOS only.
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.
If no menu is set as the Help menu, macOS will automatically use any menu which has a title matching the localized word “Help”.
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§
§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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§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