muda-win
Menu Utilities library for Desktop Applications on Windows.
This is a personal fork of muda. For general use, please consider using the original.
Notes:
- Accelerators don't work unless the win32 message loop calls
TranslateAcceleratorW. SeeMenu::init_for_hwndfor more details
Cargo Features
common-controls-v6: UseTaskDialogIndirectAPI fromComCtl32.dllv6 on Windows for showing the predefinedAboutmenu item dialog.serde: Enables de/serializing the dpi types.
Example
Create the menu and add your items
let menu = new;
let menu_item2 = new;
let submenu = with_items;
Then add your root menu to a Window.
// --snip--
unsafe ;
Context menus (Popup menus)
You can also use a [Menu] or a [Submenu] show a context menu.
// --snip--
let position = PhysicalPosition ;
unsafe ;
Processing menu events
You can use MenuEvent::receiver to get a reference to the MenuEventReceiver
which you can use to listen to events when a menu item is activated
if let Ok = receiver.try_recv
Note for winit or tao users:
You should use [MenuEvent::set_event_handler] and forward
the menu events to the event loop by using EventLoopProxy
so that the event loop is awakened on each menu event.
let event_loop = with_user_event.build.unwrap;
let proxy = event_loop.create_proxy;
set_event_handler;