Skip to content

Commit

Permalink
chore: fix egui example, loop in the thread
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Sep 4, 2023
1 parent 47bbbb1 commit 37f763f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/egui.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release

use std::time::Duration;

use eframe::egui;
use global_hotkey::{hotkey::HotKey, GlobalHotKeyEvent, GlobalHotKeyManager};
use keyboard_types::{Code, Modifiers};
Expand All @@ -8,10 +10,12 @@ fn main() -> Result<(), eframe::Error> {
let manager = GlobalHotKeyManager::new().unwrap();
let hotkey = HotKey::new(Some(Modifiers::SHIFT), Code::KeyD);
manager.register(hotkey).unwrap();
std::thread::spawn(|| {
if let Ok(event) = GlobalHotKeyEvent::receiver().try_recv() {
let receiver = GlobalHotKeyEvent::receiver();
std::thread::spawn(|| loop {
if let Ok(event) = receiver.try_recv() {
println!("tray event: {event:?}");
}
std::thread::sleep(Duration::from_millis(100));
});

let options = eframe::NativeOptions {
Expand Down

0 comments on commit 37f763f

Please sign in to comment.