mirror of
https://github.com/italicsjenga/muda.git
synced 2024-12-23 12:01:31 +11:00
.changes | ||
.github/workflows | ||
examples | ||
src | ||
.gitignore | ||
Cargo.toml | ||
README.md |
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(>k_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");
},
_ => {}
}
}