Crates.io | wcpopup |
lib.rs | wcpopup |
version | 0.1.9 |
source | src |
created_at | 2024-06-03 04:50:32.142603 |
updated_at | 2024-07-12 08:41:49.268343 |
description | Context menu for Windows |
homepage | |
repository | https://github.com/mrdkprj/wcpopup |
max_upload_size | |
id | 1259694 |
size | 83,055 |
Rust context/popup menu for Windows.
Supports dark/light theme and color/size configuration.
Use ManuBuilder to create a Menu with MenuItems, and then call Menu.popup_at() to show Menu.
When a MenuItem is clicked, SelectedMenuItem data is returned.
fn example(hwnd: HWND) {
let mut builder = MenuBuilder::new(hwnd);
builder.check("menu_item1", "Fit To Window", "", true, None);
builder.separator();
builder.text_with_accelerator("menu_item2", "Playlist", None, "Ctrl+P");
builder.text_with_accelerator("menu_item3", "Toggle Fullscreen", None, "F11");
builder.text("menu_item4", "Picture In Picture", None);
builder.separator();
builder.text_with_accelerator("menu_item5", "Capture", None, "Ctrl+S");
builder.separator();
let mut submenu = builder.submenu("Theme", None);
submenu.radio("submenu_item1", "Light", "Light", "Theme", true, None);
submenu.radio("submenu_item2", "Dark", "Dark", "Theme", false, None);
submenu.build().unwrap();
let menu = builder.build().unwrap();
let selected_item = menu.popup_at(100, 100);
}
Accelerators are used only to display available shortcut keys by default.
Use "accelerator" feature to treat accelerators as commands.
With this feature, when a shortcut key is pressed, the corresponding MenuItem is returned as the result of Menu.popup_at().
features = ["accelerator"]