From b1745a0cb2162a44deceb656f6f73e7a508696e9 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sun, 24 Nov 2024 12:50:40 +0900 Subject: [PATCH 1/4] Update lib.rs --- crates/egui-winit/src/lib.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index a78339d01fe..1a92fef7b4e 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -800,7 +800,9 @@ impl State { // contain some data even when the key is released. let is_cmd = self.egui_input.modifiers.ctrl || self.egui_input.modifiers.command - || self.egui_input.modifiers.mac_cmd; + || self.egui_input.modifiers.mac_cmd + || (self.egui_ctx.os() == egui::os::OperatingSystem::Windows + && self.egui_input.modifiers.alt); if pressed && !is_cmd { self.egui_input .events @@ -1083,6 +1085,16 @@ fn key_from_named_key(named_key: winit::keyboard::NamedKey) -> Option NamedKey::Delete => Key::Delete, NamedKey::Insert => Key::Insert, NamedKey::Escape => Key::Escape, + + NamedKey::CapsLock => Key::CapsLock, + NamedKey::NumLock => Key::NumLock, + NamedKey::ScrollLock => Key::ScrollLock, + + NamedKey::Alt => Key::Alt, + NamedKey::AltGraph => Key::AltGraph, + NamedKey::Control => Key::Control, + NamedKey::Shift => Key::Shift, + NamedKey::Cut => Key::Cut, NamedKey::Copy => Key::Copy, NamedKey::Paste => Key::Paste, @@ -1153,6 +1165,17 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option { KeyCode::PageUp => Key::PageUp, KeyCode::PageDown => Key::PageDown, + KeyCode::CapsLock => Key::CapsLock, + KeyCode::NumLock => Key::NumLock, + KeyCode::ScrollLock => Key::ScrollLock, + + KeyCode::AltLeft => Key::Alt, + KeyCode::AltRight => Key::AltGraph, + KeyCode::ControlLeft => Key::Control, + KeyCode::ControlRight => Key::ControlRight, + KeyCode::ShiftLeft => Key::Shift, + KeyCode::ShiftRight => Key::ShiftRight, + // Punctuation KeyCode::Space => Key::Space, KeyCode::Comma => Key::Comma, From 8c23f7652fc08d48bbc5ec129d5c83b919274871 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sun, 24 Nov 2024 12:51:06 +0900 Subject: [PATCH 2/4] Update key.rs --- crates/egui/src/data/key.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crates/egui/src/data/key.rs b/crates/egui/src/data/key.rs index c43d1c5685d..449d6bd7f0d 100644 --- a/crates/egui/src/data/key.rs +++ b/crates/egui/src/data/key.rs @@ -25,6 +25,17 @@ pub enum Key { PageUp, PageDown, + CapsLock, + NumLock, + ScrollLock, + + Alt, + AltGraph, + Control, + ControlRight, + Shift, + ShiftRight, + Copy, Cut, Paste, @@ -474,6 +485,17 @@ impl Key { Self::PageUp => "PageUp", Self::PageDown => "PageDown", + Self::CapsLock => "CapsLock", + Self::NumLock => "NumLock", + Self::ScrollLock => "ScrollLock", + + Self::Alt => "Alt", + Self::AltGraph => "AltGraph", + Self::Control => "Control", + Self::ControlRight => "ControlRight", + Self::Shift => "Shift", + Self::ShiftRight => "ShiftRight", + Self::Copy => "Copy", Self::Cut => "Cut", Self::Paste => "Paste", From ed45fdd76a3b50464f30ff8a0e2f5685c4df7091 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sun, 24 Nov 2024 13:02:34 +0900 Subject: [PATCH 3/4] Update key.rs --- crates/egui/src/data/key.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/egui/src/data/key.rs b/crates/egui/src/data/key.rs index 449d6bd7f0d..255c1f4233f 100644 --- a/crates/egui/src/data/key.rs +++ b/crates/egui/src/data/key.rs @@ -212,6 +212,15 @@ impl Key { Self::End, Self::PageUp, Self::PageDown, + Self::CapsLock, + Self::NumLock, + Self::ScrollLock, + Self::Alt, + Self::AltGraph, + Self::Control, + Self::ControlRight, + Self::Shift, + Self::ShiftRight, Self::Copy, Self::Cut, Self::Paste, @@ -336,6 +345,17 @@ impl Key { "PageUp" => Self::PageUp, "PageDown" => Self::PageDown, + "CapsLock" => Self::CapsLock, + "NumLock" => Self::NumLock, + "ScrollLock" => Self::ScrollLock, + + "Alt" => Self::Alt, + "AltGraph" => Self::AltGraph, + "Control" => Self::Control, + "ControlRight" => Self::ControlRight, + "Shift" => Self::Shift, + "ShiftRight" => Self::ShiftRight, + "Copy" => Self::Copy, "Cut" => Self::Cut, "Paste" => Self::Paste, From 83fbfd2dc07b3c3910ca6e5146c182dbce038302 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sun, 24 Nov 2024 14:06:31 +0900 Subject: [PATCH 4/4] Update lib.rs --- crates/egui-winit/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 1a92fef7b4e..a3cf23b9e43 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -800,9 +800,7 @@ impl State { // contain some data even when the key is released. let is_cmd = self.egui_input.modifiers.ctrl || self.egui_input.modifiers.command - || self.egui_input.modifiers.mac_cmd - || (self.egui_ctx.os() == egui::os::OperatingSystem::Windows - && self.egui_input.modifiers.alt); + || self.egui_input.modifiers.mac_cmd; if pressed && !is_cmd { self.egui_input .events