LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
KEY-CLIPBOARD: Shift+Insert pastes settings plainly on Windows
Nathaniel Ledford2e23c767b4c4
diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rsindex d86b61f98..c47566dc3 100644--- a/crates/ui-egui/src/shortcuts.rs+++ b/crates/ui-egui/src/shortcuts.rs@@ -261,8 +261,9 @@ pub fn parse(s: &str) -> Option<(Modifiers, Key)> {fn matches(i: &egui::InputState, m: Modifiers, k: Key) -> bool {// the windowing layer turns ⌘C / ⌘X / ⌘V (with any other modifiers held) and the keyboard's- // Copy / Cut / Paste keys into these on Windows and Linux (macOS's menu bar takes them first)- let clipboard = Modifiers { command: true, ..i.modifiers };+ // Copy / Cut / Paste keys into these on Windows and Linux (macOS's menu bar takes them first);+ // without ⌘/Ctrl held they came from a key that is the plain command (Windows' ⇧Insert pastes)+ let clipboard = if i.modifiers.command { i.modifiers } else { Modifiers::COMMAND };i.events.iter().any(|e| {let (key, physical_key, modifiers) = match e {egui::Event::Key { key, physical_key, pressed: true, modifiers, .. } => (key, physical_key, modifiers),diff --git a/crates/ui-egui/src/tests_keymap.rs b/crates/ui-egui/src/tests_keymap.rsindex e59158b11..0bd55f413 100644--- a/crates/ui-egui/src/tests_keymap.rs+++ b/crates/ui-egui/src/tests_keymap.rs@@ -162,3 +162,17 @@ fn clipboard_events_run_the_copy_and_paste_shortcuts() {h.settle(SETTLE);assert!(matches!(h.app.ui.dialog, Some(Dialog::PasteSettings { .. })), "⇧Ctrl+V: {:?}", h.app.ui.dialog);}++/// Windows also pastes with ⇧Insert and cuts with ⇧Delete: the clipboard events they become are+/// the plain Paste / Cut, not ⇧Ctrl+V (Paste Selected Settings).+#[test]+fn shift_insert_pastes_plainly() {+ let mut h = demo();+ h.events.push(egui::Event::Copy);+ h.settle(SETTLE);+ let undo = h.app.session.undo.len();+ h.events.extend([egui::Event::ModifiersChanged(egui::Modifiers::SHIFT), egui::Event::Paste("text".into())]);+ h.settle(SETTLE);+ assert_eq!(h.app.ui.dialog, None, "no Paste Selected Settings");+ assert_eq!(h.app.session.undo.len(), undo + 1, "the settings were pasted");+}