diff --git a/.changes/docs.md b/.changes/docs.md new file mode 100644 index 0000000..a277e40 --- /dev/null +++ b/.changes/docs.md @@ -0,0 +1,5 @@ +--- +"muda": "patch" +--- + +Update docs diff --git a/README.md b/README.md index d3a3db4..ad4cd14 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,33 @@ muda is a Menu Utilities library for Desktop Applications. +## Platforms supported: + +- Windows +- macOS +- Linux (gtk Only) + +## Platform-specific notes: + +- On Windows, accelerators don't work unless the win32 message loop calls + [`TranslateAcceleratorW`](https://docs.rs/windows-sys/latest/windows_sys/Win32/UI/WindowsAndMessaging/fn.TranslateAcceleratorW.html). + See [`Menu::init_for_hwnd`](https://docs.rs/muda/latest/muda/struct.Menu.html#method.init_for_hwnd) for more details + +## Dependencies (Linux Only) + +`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: + +#### Arch Linux / Manjaro: + +```sh +pacman -S gtk3 xdotool +``` + +#### Debian / Ubuntu: + +```sh +sudo apt install libgtk-3-dev libxdo-dev +``` + ## Example Create the menu and add your items @@ -50,10 +78,12 @@ menu.show_context_menu_for_gtk_window(>k_window, x, y); #[cfg(target_os = "macos")] menu.show_context_menu_for_nsview(nsview, x, y); ``` + ## 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 + ```rs if let Ok(event) = MenuEvent::receiver().try_recv() { match event.id { @@ -65,29 +95,6 @@ if let Ok(event) = MenuEvent::receiver().try_recv() { } ``` -## Platform-specific notes: - -### Accelerators on Windows - -Accelerators don't work unless the win32 message loop calls -[`TranslateAcceleratorW`](https://docs.rs/windows-sys/latest/windows_sys/Win32/UI/WindowsAndMessaging/fn.TranslateAcceleratorW.html) - -See [`Menu::init_for_hwnd`](https://docs.rs/muda/latest/muda/struct.Menu.html#method.init_for_hwnd) for more details - -### Linux - -`libxdo` is used to make the predfined `Copy`, `Cut`, `Paste` and `SelectAll` menu items work. Be sure to install following packages before building: - -Arch Linux / Manjaro: -```sh -pacman -S xdotool -``` - -Debian / Ubuntu: -```sh -sudo apt install libxdo-dev -``` - ## License Apache-2.0/MIT diff --git a/examples/tao.rs b/examples/tao.rs index 906917f..b7b45bd 100644 --- a/examples/tao.rs +++ b/examples/tao.rs @@ -190,7 +190,7 @@ fn main() { if event.id == custom_i_1.id() { file_m.insert(&MenuItem::new("New Menu Item", true, None), 2); } - println!("{:?}", event); + println!("{event:?}"); } }) } diff --git a/examples/winit.rs b/examples/winit.rs index 3ad03b8..793d57d 100644 --- a/examples/winit.rs +++ b/examples/winit.rs @@ -180,7 +180,7 @@ fn main() { if event.id == custom_i_1.id() { file_m.insert(&MenuItem::new("New Menu Item", true, None), 2); } - println!("{:?}", event); + println!("{event:?}"); } }) } diff --git a/src/lib.rs b/src/lib.rs index 2679373..d92d16b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,8 +2,38 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(clippy::uninlined_format_args)] + //! muda is a Menu Utilities library for Desktop Applications. //! +//! # Platforms supported: +//! +//! - Windows +//! - macOS +//! - Linux (gtk Only) +//! +//! # Platform-specific notes: +//! +//! - On Windows, accelerators don't work unless the win32 message loop calls +//! [`TranslateAcceleratorW`](https://docs.rs/windows-sys/latest/windows_sys/Win32/UI/WindowsAndMessaging/fn.TranslateAcceleratorW.html). +//! See [`Menu::init_for_hwnd`](https://docs.rs/muda/latest/muda/struct.Menu.html#method.init_for_hwnd) for more details +//! +//! # Dependencies (Linux Only) +//! +//! `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: +//! +//! #### Arch Linux / Manjaro: +//! +//! ```sh +//! pacman -S gtk3 xdotool +//! ``` +//! +//! #### Debian / Ubuntu: +//! +//! ```sh +//! sudo apt install libgtk-3-dev libxdo-dev +//! ``` +//! //! # Example //! //! Create the menu and add your items @@ -94,13 +124,6 @@ //! } //! } //! ``` -//! -//! # Accelerators on Windows -//! -//! Accelerators don't work unless the win32 message loop calls -//! [`TranslateAcceleratorW`](windows_sys::Win32::UI::WindowsAndMessaging::TranslateAcceleratorW) -//! -//! See [`Menu::init_for_hwnd`] for more details use crossbeam_channel::{unbounded, Receiver, Sender}; use once_cell::sync::{Lazy, OnceCell};