pub struct Menu { /* private fields */ }Expand description
A menu object, which can be either a top-level menubar or a submenu.
Implementations§
Source§impl Menu
impl Menu
Sourcepub fn new() -> Menu
pub fn new() -> Menu
Examples found in repository?
examples/hello.rs (line 101)
98fn main() {
99 druid_win_shell::init();
100
101 let mut file_menu = Menu::new();
102 file_menu.add_item(0x100, "E&xit");
103 file_menu.add_item(0x101, "O&pen");
104 let mut menubar = Menu::new();
105 menubar.add_dropdown(file_menu, "&File");
106
107 let mut run_loop = win_main::RunLoop::new();
108 let mut builder = WindowBuilder::new();
109 builder.set_handler(Box::new(HelloState::default()));
110 builder.set_title("Hello example");
111 builder.set_menu(menubar);
112 let window = builder.build().unwrap();
113 window.show();
114 run_loop.run();
115}Sourcepub fn add_dropdown(&mut self, menu: Menu, text: &str)
pub fn add_dropdown(&mut self, menu: Menu, text: &str)
Add a dropdown menu. This takes the menu by ownership, but we’ll probably want to change that so we can manipulate it later.
The text field has all the fun behavior of winapi CreateMenu.
Examples found in repository?
examples/hello.rs (line 105)
98fn main() {
99 druid_win_shell::init();
100
101 let mut file_menu = Menu::new();
102 file_menu.add_item(0x100, "E&xit");
103 file_menu.add_item(0x101, "O&pen");
104 let mut menubar = Menu::new();
105 menubar.add_dropdown(file_menu, "&File");
106
107 let mut run_loop = win_main::RunLoop::new();
108 let mut builder = WindowBuilder::new();
109 builder.set_handler(Box::new(HelloState::default()));
110 builder.set_title("Hello example");
111 builder.set_menu(menubar);
112 let window = builder.build().unwrap();
113 window.show();
114 run_loop.run();
115}Sourcepub fn add_item(&mut self, id: u32, text: &str)
pub fn add_item(&mut self, id: u32, text: &str)
Add an item to the menu.
Examples found in repository?
examples/hello.rs (line 102)
98fn main() {
99 druid_win_shell::init();
100
101 let mut file_menu = Menu::new();
102 file_menu.add_item(0x100, "E&xit");
103 file_menu.add_item(0x101, "O&pen");
104 let mut menubar = Menu::new();
105 menubar.add_dropdown(file_menu, "&File");
106
107 let mut run_loop = win_main::RunLoop::new();
108 let mut builder = WindowBuilder::new();
109 builder.set_handler(Box::new(HelloState::default()));
110 builder.set_title("Hello example");
111 builder.set_menu(menubar);
112 let window = builder.build().unwrap();
113 window.show();
114 run_loop.run();
115}Sourcepub fn add_separator(&mut self)
pub fn add_separator(&mut self)
Add a separator to the 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
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