Skip to content

Commit

Permalink
chore: update egui example to use thread
Browse files Browse the repository at this point in the history
closes #31
  • Loading branch information
amrbashir committed Sep 4, 2023
1 parent 49d9b0e commit 47bbbb1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/egui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ use keyboard_types::{Code, Modifiers};
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() {
println!("tray event: {event:?}");
}
});

let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(320.0, 240.0)),
Expand Down Expand Up @@ -38,10 +42,6 @@ impl Default for MyApp {

impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
if let Ok(event) = GlobalHotKeyEvent::receiver().try_recv() {
println!("tray event: {event:?}");
}

egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My egui Application");
ui.horizontal(|ui| {
Expand Down

0 comments on commit 47bbbb1

Please sign in to comment.