pub struct Menu { /* private fields */ }
Expand description
A menu, which contains zero or more items
Implementations§
source§impl Menu
impl Menu
sourcepub fn new<S: Into<String>>(name: S) -> Result<Self, NulError>
pub fn new<S: Into<String>>(name: S) -> Result<Self, NulError>
Creates a new menu with the provided name
Returns an error if the name contains a null byte
Examples found in repository?
examples/menus.rs (line 20)
19 20 21 22 23 24 25 26 27 28 29 30
fn start() -> Result<Self, Self::Error> {
let plugins_submenu = Menu::new("Menu Test Plugin").unwrap();
plugins_submenu.add_child(CheckItem::new("Checkable 1", false, CheckHandler1).unwrap());
plugins_submenu.add_child(ActionItem::new("Action 1", ActionHandler1).unwrap());
plugins_submenu.add_to_plugins_menu();
// The menu needs to be part of the plugin struct, or it will immediately get dropped and
// will not appear
Ok(MenuPlugin {
_plugins_submenu: plugins_submenu,
})
}
sourcepub fn set_name<S: AsRef<str>>(&self, name: S) -> Result<(), NulError>
pub fn set_name<S: AsRef<str>>(&self, name: S) -> Result<(), NulError>
Sets the name of this menu
Returns an error if the name contains a null byte
sourcepub fn add_child<R, C>(&self, child: R)
pub fn add_child<R, C>(&self, child: R)
Adds a child to this menu The child argument may be a Menu, ActionItem, CheckItem, or Separator, or an Rc containing one of these types.
Examples found in repository?
examples/menus.rs (line 21)
19 20 21 22 23 24 25 26 27 28 29 30
fn start() -> Result<Self, Self::Error> {
let plugins_submenu = Menu::new("Menu Test Plugin").unwrap();
plugins_submenu.add_child(CheckItem::new("Checkable 1", false, CheckHandler1).unwrap());
plugins_submenu.add_child(ActionItem::new("Action 1", ActionHandler1).unwrap());
plugins_submenu.add_to_plugins_menu();
// The menu needs to be part of the plugin struct, or it will immediately get dropped and
// will not appear
Ok(MenuPlugin {
_plugins_submenu: plugins_submenu,
})
}
Adds this menu as a child of the plugins menu
Examples found in repository?
examples/menus.rs (line 23)
19 20 21 22 23 24 25 26 27 28 29 30
fn start() -> Result<Self, Self::Error> {
let plugins_submenu = Menu::new("Menu Test Plugin").unwrap();
plugins_submenu.add_child(CheckItem::new("Checkable 1", false, CheckHandler1).unwrap());
plugins_submenu.add_child(ActionItem::new("Action 1", ActionHandler1).unwrap());
plugins_submenu.add_to_plugins_menu();
// The menu needs to be part of the plugin struct, or it will immediately get dropped and
// will not appear
Ok(MenuPlugin {
_plugins_submenu: plugins_submenu,
})
}
Removes this menu from the plugins menu
Trait Implementations§
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