wcpopup

Crates.iowcpopup
lib.rswcpopup
version0.1.9
sourcesrc
created_at2024-06-03 04:50:32.142603
updated_at2024-07-12 08:41:49.268343
descriptionContext menu for Windows
homepage
repositoryhttps://github.com/mrdkprj/wcpopup
max_upload_size
id1259694
size83,055
(mrdkprj)

documentation

https://docs.rs/wcpopup/0.1.10/wcpopup/

README

wcpopup

Rust context/popup menu for Windows.
Supports dark/light theme and color/size configuration.

  • Colors
    • Text color
    • Background color
    • Border color
  • Size
    • Menu top/bottom margin
    • Menu item top/bottom and left/right padding
    • Font size/weight

samplesample

Usage

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);
}

Accelerator

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"]
Commit count: 28

cargo fmt