Menu

Struct Menu 

Source
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

Source

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}
Source

pub fn into_hmenu(self) -> HMENU

Source

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}
Source

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}
Source

pub fn add_separator(&mut self)

Add a separator to the menu.

Trait Implementations§

Source§

impl Drop for Menu

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.