{"id":15013126,"url":"https://github.com/tauri-apps/muda","last_synced_at":"2025-12-12T15:15:41.826Z","repository":{"id":37013487,"uuid":"488951773","full_name":"tauri-apps/muda","owner":"tauri-apps","description":"Menu Utilities for Desktop Applications in Rust.","archived":false,"fork":false,"pushed_at":"2025-04-30T16:26:37.000Z","size":756,"stargazers_count":324,"open_issues_count":36,"forks_count":32,"subscribers_count":13,"default_branch":"dev","last_synced_at":"2025-05-15T09:26:31.122Z","etag":null,"topics":["gui","menu","rust","windowing"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tauri-apps.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-05T11:51:19.000Z","updated_at":"2025-05-14T11:36:07.000Z","dependencies_parsed_at":"2023-11-20T19:39:28.293Z","dependency_job_id":"786eabff-52a2-47ce-a7ce-6b3a0f464fd1","html_url":"https://github.com/tauri-apps/muda","commit_stats":{"total_commits":236,"total_committers":15,"mean_commits":"15.733333333333333","dds":"0.47881355932203384","last_synced_commit":"cea276a3c95b638ade3f7119dd887e91f4dee2b6"},"previous_names":["amrbashir/muda","amrbashir/minit"],"tags_count":70,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Fmuda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Fmuda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Fmuda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Fmuda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tauri-apps","download_url":"https://codeload.github.com/tauri-apps/muda/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471061,"owners_count":22076585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gui","menu","rust","windowing"],"created_at":"2024-09-24T19:43:46.580Z","updated_at":"2025-12-12T15:15:41.778Z","avatar_url":"https://github.com/tauri-apps.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"### muda\n\nMenu Utilities library for Desktop Applications.\n\n[![Documentation](https://img.shields.io/docsrs/muda)](https://docs.rs/muda/latest/muda/)\n\n## Platforms supported:\n\n- Windows\n- macOS\n- Linux (gtk Only)\n\n## Platform-specific notes:\n\n- On Windows, accelerators don't work unless the win32 message loop calls\n  [`TranslateAcceleratorW`](https://docs.rs/windows-sys/latest/windows_sys/Win32/UI/WindowsAndMessaging/fn.TranslateAcceleratorW.html).\n  See [`Menu::init_for_hwnd`](https://docs.rs/muda/latest/x86_64-pc-windows-msvc/muda/struct.Menu.html#method.init_for_hwnd) for more details\n\n### Cargo Features\n\n- `common-controls-v6`: Use `TaskDialogIndirect` API from `ComCtl32.dll` v6 on Windows for showing the predefined `About` menu item dialog.\n- `libxdo`: Enables linking to `libxdo` on Linux which is used for the predefined `Copy`, `Cut`, `Paste` and `SelectAll` menu item.\n- `serde`: Enables de/serializing the dpi types.\n- `gtk`: Enables the `gtk` crate dependency on Linux. This is required for `muda` to function properly on Linux.\n\n## Dependencies (Linux Only)\n\n`gtk` is used for menus and `libxdo` is used to make the predfined `Copy`, `Cut`, `Paste` and `SelectAll` menu items work. Be sure to install following packages before building:\n\n#### Arch Linux / Manjaro:\n\n```sh\npacman -S gtk3 xdotool\n```\n\n#### Debian / Ubuntu:\n\n```sh\nsudo apt install libgtk-3-dev libxdo-dev\n```\n\n## Example\n\nCreate the menu and add your items\n\n```rs\nlet menu = Menu::new();\nlet menu_item2 = MenuItem::new(\"Menu item #2\", false, None);\nlet submenu = Submenu::with_items(\"Submenu Outer\", true,\u0026[\n  \u0026MenuItem::new(\"Menu item #1\", true, Some(Accelerator::new(Some(Modifiers::ALT), Code::KeyD))),\n  \u0026PredefinedMenuItem::separator(),\n  \u0026menu_item2,\n  \u0026MenuItem::new(\"Menu item #3\", true, None),\n  \u0026PredefinedMenuItem::separator(),\n  \u0026Submenu::with_items(\"Submenu Inner\", true,\u0026[\n    \u0026MenuItem::new(\"Submenu item #1\", true, None),\n    \u0026PredefinedMenuItem::separator(),\n    \u0026menu_item2,\n  ])\n]);\n\n```\n\nThen add your root menu to a Window on Windows and Linux\nor use it as your global app menu on macOS\n\n```rs\n// --snip--\n#[cfg(target_os = \"windows\")]\nunsafe { menu.init_for_hwnd(window.hwnd() as isize) };\n#[cfg(target_os = \"linux\")]\nmenu.init_for_gtk_window(\u0026gtk_window, Some(\u0026vertical_gtk_box));\n#[cfg(target_os = \"macos\")]\nmenu.init_for_nsapp();\n```\n\n## Context menus (Popup menus)\n\nYou can also use a [`Menu`] or a [`Submenu`] show a context menu.\n\n```rs\n// --snip--\nlet position = muda::PhysicalPosition { x: 100., y: 120. };\n#[cfg(target_os = \"windows\")]\nunsafe { menu.show_context_menu_for_hwnd(window.hwnd() as isize, Some(position.into())) };\n#[cfg(target_os = \"linux\")]\nmenu.show_context_menu_for_gtk_window(\u0026gtk_window, Some(position.into()));\n#[cfg(target_os = \"macos\")]\nunsafe { menu.show_context_menu_for_nsview(nsview, Some(position.into())) };\n```\n\n## Processing menu events\n\nYou can use `MenuEvent::receiver` to get a reference to the `MenuEventReceiver`\nwhich you can use to listen to events when a menu item is activated\n\n```rs\nif let Ok(event) = MenuEvent::receiver().try_recv() {\n    match event.id {\n        _ if event.id == save_item.id() =\u003e {\n            println!(\"Save menu item activated\");\n        },\n        _ =\u003e {}\n    }\n}\n```\n\n### Note for [winit] or [tao] users:\n\nYou should use [`MenuEvent::set_event_handler`] and forward\nthe menu events to the event loop by using [`EventLoopProxy`]\nso that the event loop is awakened on each menu event.\n\n```rust\nenum UserEvent {\n  MenuEvent(muda::MenuEvent)\n}\n\nlet event_loop = EventLoop::\u003cUserEvent\u003e::with_user_event().build().unwrap();\n\nlet proxy = event_loop.create_proxy();\nmuda::MenuEvent::set_event_handler(Some(move |event| {\n    proxy.send_event(UserEvent::MenuEvent(event));\n}));\n```\n\n[`EventLoopProxy`]: https://docs.rs/winit/latest/winit/event_loop/struct.EventLoopProxy.html\n[winit]: https://docs.rs/winit\n[tao]: https://docs.rs/tao\n\n## License\n\nApache-2.0/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftauri-apps%2Fmuda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftauri-apps%2Fmuda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftauri-apps%2Fmuda/lists"}