From 221a77dd5b9acaee205c294439856adc4665983a Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Wed, 17 Jan 2024 12:13:11 +0100 Subject: [PATCH] egui-winit: Don't consume clipboard shortcuts (#3812) This breaking change seems to have snuck in during #3649. Previously it would never consume these, today it consumes them unconditionally, and with this change it'll ~~only consume them if egui wants text input~~ never consume them. This is a blocker for updating our application, sadly :( --- crates/egui-winit/src/lib.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index c891765d428..34d5bbeb6bb 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -341,9 +341,10 @@ impl State { } } WindowEvent::KeyboardInput { event, .. } => { + self.on_keyboard_input(event); + // When pressing the Tab key, egui focuses the first focusable element, hence Tab always consumes. - let consumed = self.on_keyboard_input(event) - || self.egui_ctx.wants_keyboard_input() + let consumed = self.egui_ctx.wants_keyboard_input() || event.logical_key == winit::keyboard::Key::Named(winit::keyboard::NamedKey::Tab); EventResponse { @@ -653,7 +654,7 @@ impl State { } } - fn on_keyboard_input(&mut self, event: &winit::event::KeyEvent) -> bool { + fn on_keyboard_input(&mut self, event: &winit::event::KeyEvent) { let winit::event::KeyEvent { // Represents the position of a key independent of the currently active layout. // @@ -702,10 +703,10 @@ impl State { if pressed { if is_cut_command(self.egui_input.modifiers, logical_key) { self.egui_input.events.push(egui::Event::Cut); - return true; + return; } else if is_copy_command(self.egui_input.modifiers, logical_key) { self.egui_input.events.push(egui::Event::Copy); - return true; + return; } else if is_paste_command(self.egui_input.modifiers, logical_key) { if let Some(contents) = self.clipboard.get() { let contents = contents.replace("\r\n", "\n"); @@ -713,7 +714,7 @@ impl State { self.egui_input.events.push(egui::Event::Paste(contents)); } } - return true; + return; } } @@ -744,8 +745,6 @@ impl State { } } } - - false } /// Call with the output given by `egui`.