mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-26 11:09:23 -06:00
KEY-CLIPBOARD: Shift+Insert pastes settings plainly on Windows
egui-winit also sends a paste for Windows' Shift+Insert (and a cut for Shift+Delete): read with the Shift held, it matched ⇧Ctrl+V and opened Paste Selected Settings. A clipboard event with no Ctrl/⌘ held is now the plain command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a6e59cc5b3
commit
2e23c767b4
@@ -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),
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user