Go to file
Jason Tsai 01e7a2a848
feat(macos): add accelerator (#12)
* feat(macos): add accelerator

* chore(macos): todo add_native_item

to make compile works

* Update src/platform_impl/macos/accelerator.rs

Should just remove an ampersand here

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>

* fix: save original label for later use

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
2022-06-12 10:25:15 +02:00
examples feat: implement NativeMenuItem (#9) 2022-06-10 14:09:56 +02:00
src feat(macos): add accelerator (#12) 2022-06-12 10:25:15 +02:00
.gitignore init - initial linux support 2022-05-05 13:50:22 +02:00
Cargo.toml feat: implement NativeMenuItem (#9) 2022-06-10 14:09:56 +02:00
README.md feat: add menu hide, show and remove (#8) 2022-06-07 18:32:10 +02:00

muda

Menu Utilities for Desktop Applications.

Example

Create the root menu and add submenus and men items.

let mut menu = Menu::new();

let file_menu = menu.add_submenu("File", true);
let open_item = file_menu.add_text_item("Open", true);
let save_item = file_menu.add_text_item("Save", true);

let edit_menu = menu.add_submenu("Edit", true);
let copy_item = file_menu.add_text_item("Copy", true);
let cut_item = file_menu.add_text_item("Cut", true);

#[cfg(target_os = "windows")]
menu.init_for_hwnd(window.hwnd() as isize);
#[cfg(target_os = "linux")]
menu.init_for_gtk_window(&gtk_window);
#[cfg(target_os = "macos")]
menu.init_for_nsapp();

Then listen for the events

if let Ok(event) = menu_event_receiver().try_recv() {
    match event.id {
        _ if event.id == save_item.id() => {
            println!("Save menu item activated");
        },
        _ => {}
    }
}