From fc118f17102e8874c52350c7fd37dff8cc8bfab7 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 14 Oct 2026 15:04:42 -0400 Subject: [PATCH] Fix up #88: an image paste needs Command/Ctrl held on the V release Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/lib.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 704dba95..a9258ce1 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1018,7 +1018,11 @@ impl SlideApp { for e in &events { match e { egui::Event::Paste(_) | egui::Event::Key { key: egui::Key::V, pressed: true, .. } => self.v_seen = true, - egui::Event::Key { key: egui::Key::V, pressed: false, .. } => image_paste = !std::mem::take(&mut self.v_seen), + egui::Event::Key { key: egui::Key::V, pressed: false, modifiers, .. } => { + // Only a release with Command/Ctrl held is a paste: a bare V release is not. + let seen = std::mem::take(&mut self.v_seen); + image_paste = !seen && (modifiers.command || modifiers.ctrl); + } _ => {} } } @@ -1633,6 +1637,10 @@ mod tests { harness.event(v(false)); harness.run_steps(2); assert_eq!(pictures(harness.state()), 0); + // A V release without Command/Ctrl is not a paste. + harness.event(egui::Event::Key { key: egui::Key::V, physical_key: None, pressed: false, repeat: false, modifiers: egui::Modifiers::NONE }); + harness.run_steps(2); + assert_eq!(pictures(harness.state()), 0); // What egui-winit sends for Ctrl+V with only an image on the clipboard: the release alone. harness.event(v(false)); harness.run_steps(2);