docs: update docs

This commit is contained in:
amrbashir
2023-02-08 21:11:29 +02:00
parent 56f4e03c27
commit 6409e5dd35
5 changed files with 32 additions and 9 deletions

5
.changes/docs.md Normal file
View File

@@ -0,0 +1,5 @@
---
"global-hotkey": "patch"
---
Update docs

View File

@@ -1,5 +1,16 @@
global_hotkey lets you register Global HotKeys for Desktop Applications.
## Platforms-supported:
- Windows
- macOS
- Linux (X11 Only)
## Platform-specific notes:
- On Windows a win32 event loop must be running on the thread. It doesn't need to be the main thread but you have to create the global hotkey manager on the same thread as the event loop.
- On macOS, an event loop must be running on the main thread so you also need to create the global hotkey manager on the main thread.
## Example
```rs
@@ -15,10 +26,10 @@ let hotkey = HotKey::new(Some(Modifiers::SHIFT), Code::KeyD);
manager.register(hotkey);
```
## Processing global hotkey events
You can also listen for the menu events using `GlobalHotKeyEvent::receiver` to get events for the hotkey pressed events.
```rs
use global_hotkey::GlobalHotKeyEvent;
@@ -27,12 +38,6 @@ if let Ok(event) = GlobalHotKeyEvent::receiver().try_recv() {
}
```
## Platforms-supported:
- Windows
- macOS
- Linux (X11 Only)
## License
Apache-2.0/MIT

View File

@@ -27,7 +27,7 @@ fn main() {
*control_flow = ControlFlow::Poll;
if let Ok(event) = global_hotkey_channel.try_recv() {
println!("{:?}", event);
println!("{event:?}");
if hotkey2.id() == event.id {
hotkeys_manager.unregister(hotkey2).unwrap();

View File

@@ -27,7 +27,7 @@ fn main() {
*control_flow = ControlFlow::Poll;
if let Ok(event) = global_hotkey_channel.try_recv() {
println!("{:?}", event);
println!("{event:?}");
if hotkey2.id() == event.id {
hotkeys_manager.unregister(hotkey2).unwrap();

View File

@@ -2,8 +2,21 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
#![allow(clippy::uninlined_format_args)]
//! global_hotkey lets you register Global HotKeys for Desktop Applications.
//!
//! ## Platforms-supported:
//!
//! - Windows
//! - macOS
//! - Linux (X11 Only)
//!
//! ## Platform-specific notes:
//!
//! - On Windows a win32 event loop must be running on the thread. It doesn't need to be the main thread but you have to create the global hotkey manager on the same thread as the event loop.
//! - On macOS, an event loop must be running on the main thread so you also need to create the global hotkey manager on the main thread.
//!
//! # Example
//!
//! ```no_run