mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-24 10:37:03 -06:00
Fix up #88: an image paste needs Command/Ctrl held on the V release
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
1481c2d3f0
commit
fc118f1710
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user