22 releases

0.2.3 Aug 22, 2024
0.2.2 Aug 20, 2024
0.1.18 Aug 2, 2024
0.1.17 Jul 28, 2024
0.1.6 Jun 24, 2024

#115 in GUI

Download history 357/week @ 2024-06-01 27/week @ 2024-06-08 404/week @ 2024-06-15 164/week @ 2024-06-22 291/week @ 2024-06-29 149/week @ 2024-07-06 148/week @ 2024-07-13 563/week @ 2024-07-20 366/week @ 2024-07-27 34/week @ 2024-08-03 5/week @ 2024-08-10 524/week @ 2024-08-17 27/week @ 2024-08-24

679 downloads per month

MIT license

110KB
2.5K SLoC

wcpopup

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

  • Colors
    • Text color
    • Background color
    • Border color
  • Size
    • Menu padding
    • Menu item padding
  • Font
    • Font family
    • Size and 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(window_handle: isize) {
    let mut builder = MenuBuilder::new(window_handle);
    // Using HWND
    // let mut builder = MenuBuilder::new_for_hwnd(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("submenu1", "Theme", None);
    submenu.radio("submenu_item1", "Light", "Theme", true, None);
    submenu.radio("submenu_item2", "Dark", "Theme", false, None);
    submenu.build().unwrap();

    let menu = builder.build().unwrap();

    let selected_item = menu.popup_at(100, 100);
    // On a separate thread
    // async_std::task::spawn(async move {
    //   let selected_item = menu.popup_at_async(100, 100).await
    // });
}

WebView2 may receive all keyboard input instead of its parent window(#1703).
Using WebView2, you may need to enable the feature flag.

--enable-features=msWebView2BrowserHitTransparent

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"]

Dependencies

~129MB
~2M SLoC