From 84a1842f3d4b311674eed9007594b64ddc22451e Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Wed, 15 May 2024 04:05:11 +0200 Subject: [PATCH] egui: add Ctrl+Z and Ctrl+Y key shortcuts for Undo and Redo --- src/bin/topola-egui/app.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bin/topola-egui/app.rs b/src/bin/topola-egui/app.rs index b49e288..72b5a62 100644 --- a/src/bin/topola-egui/app.rs +++ b/src/bin/topola-egui/app.rs @@ -240,7 +240,9 @@ impl eframe::App for App { } } - if ui.button("Undo").clicked() { + if ui.button("Undo").clicked() + || ctx.input_mut(|i| i.consume_key(egui::Modifiers::CTRL, egui::Key::Z)) + { if let Some(invoker_arc_mutex) = &self.invoker { let invoker_arc_mutex = invoker_arc_mutex.clone(); execute(async move { @@ -249,7 +251,9 @@ impl eframe::App for App { } } - if ui.button("Redo").clicked() { + if ui.button("Redo").clicked() + || ctx.input_mut(|i| i.consume_key(egui::Modifiers::CTRL, egui::Key::Y)) + { if let Some(invoker_arc_mutex) = &self.invoker { let invoker_arc_mutex = invoker_arc_mutex.clone(); execute(async move {