mirror of
https://github.com/italicsjenga/muda.git
synced 2024-12-23 20:11:29 +11:00
docs: update docs
This commit is contained in:
parent
d7905d5f22
commit
4b2ebc247c
5
.changes/docs.md
Normal file
5
.changes/docs.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"muda": "patch"
|
||||
---
|
||||
|
||||
Update docs
|
53
README.md
53
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
|
||||
|
|
|
@ -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:?}");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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:?}");
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
37
src/lib.rs
37
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};
|
||||
|
|
Loading…
Reference in a new issue