From ed1afcdf372e437a2833eab52bb57eef2a7a4d6a Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sun, 24 Nov 2024 14:29:54 +0900 Subject: [PATCH 1/6] Update lib.rs --- crates/egui-winit/src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index a78339d01fe..37dc8367da4 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -1083,6 +1083,15 @@ 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::Control => Key::Control, + NamedKey::Shift => Key::Shift, + NamedKey::Cut => Key::Cut, NamedKey::Copy => Key::Copy, NamedKey::Paste => Key::Paste, @@ -1153,6 +1162,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::AltRight, + 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 c71b9d5cce01fa0e4d78cd01235112a35437081e Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Sun, 24 Nov 2024 14:30:24 +0900 Subject: [PATCH 2/6] Update key.rs --- crates/egui/src/data/key.rs | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/crates/egui/src/data/key.rs b/crates/egui/src/data/key.rs index c43d1c5685d..75f9ed1b65d 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, + AltRight, + Control, + ControlRight, + Shift, + ShiftRight, + Copy, Cut, Paste, @@ -201,6 +212,15 @@ impl Key { Self::End, Self::PageUp, Self::PageDown, + Self::CapsLock, + Self::NumLock, + Self::ScrollLock, + Self::Alt, + Self::AltRight, + Self::Control, + Self::ControlRight, + Self::Shift, + Self::ShiftRight, Self::Copy, Self::Cut, Self::Paste, @@ -325,6 +345,17 @@ impl Key { "PageUp" => Self::PageUp, "PageDown" => Self::PageDown, + "CapsLock" => Self::CapsLock, + "NumLock" => Self::NumLock, + "ScrollLock" => Self::ScrollLock, + + "Alt" => Self::Alt, + "AltRight" => Self::AltRight, + "Control" => Self::Control, + "ControlRight" => Self::ControlRight, + "Shift" => Self::Shift, + "ShiftRight" => Self::ShiftRight, + "Copy" => Self::Copy, "Cut" => Self::Cut, "Paste" => Self::Paste, @@ -474,6 +505,17 @@ impl Key { Self::PageUp => "PageUp", Self::PageDown => "PageDown", + Self::CapsLock => "CapsLock", + Self::NumLock => "NumLock", + Self::ScrollLock => "ScrollLock", + + Self::Alt => "Alt", + Self::AltRight => "AltRight", + Self::Control => "Control", + Self::ControlRight => "ControlRight", + Self::Shift => "Shift", + Self::ShiftRight => "ShiftRight", + Self::Copy => "Copy", Self::Cut => "Cut", Self::Paste => "Paste", From 2e45092753c954fac5bc610da9768df720a6b860 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Thu, 5 Dec 2024 02:22:52 +0900 Subject: [PATCH 3/6] Update lib.rs --- crates/egui-winit/src/lib.rs | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 37dc8367da4..8307a9a00a8 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -758,11 +758,11 @@ impl State { physical_key ); - // "Logical OR physical key" is a fallback mechanism for keyboard layouts without Latin characters: it lets them + // "physical OR logical key" is a fallback mechanism for keyboard layouts without Latin characters: it lets them // emit events as if the corresponding keys from the Latin layout were pressed. In this case, clipboard shortcuts // are mapped to the physical keys that normally contain C, X, V, etc. // See also: https://github.com/emilk/egui/issues/3653 - if let Some(active_key) = logical_key.or(physical_key) { + if let Some(active_key) = physical_key.or(logical_key) { if pressed { if is_cut_command(self.egui_input.modifiers, active_key) { self.egui_input.events.push(egui::Event::Cut); @@ -1084,14 +1084,14 @@ fn key_from_named_key(named_key: winit::keyboard::NamedKey) -> Option 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::Control => Key::Control, NamedKey::Shift => Key::Shift, + NamedKey::CapsLock => Key::CapsLock, + NamedKey::NumLock => Key::NumLock, + NamedKey::ScrollLock => Key::ScrollLock, + NamedKey::Cut => Key::Cut, NamedKey::Copy => Key::Copy, NamedKey::Paste => Key::Paste, @@ -1145,6 +1145,7 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option { use winit::keyboard::KeyCode; Some(match key { + // Commands: KeyCode::ArrowDown => Key::ArrowDown, KeyCode::ArrowLeft => Key::ArrowLeft, KeyCode::ArrowRight => Key::ArrowRight, @@ -1162,10 +1163,6 @@ 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::AltRight, KeyCode::ControlLeft => Key::Control, @@ -1173,6 +1170,14 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option { KeyCode::ShiftLeft => Key::Shift, KeyCode::ShiftRight => Key::ShiftRight, + KeyCode::CapsLock => Key::CapsLock, + KeyCode::NumLock => Key::NumLock, + KeyCode::ScrollLock => Key::ScrollLock, + + KeyCode::Cut => Key::Cut, + KeyCode::Copy => Key::Copy, + KeyCode::Paste => Key::Paste, + // Punctuation KeyCode::Space => Key::Space, KeyCode::Comma => Key::Comma, @@ -1186,9 +1191,6 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option { KeyCode::Backquote => Key::Backtick, KeyCode::Quote => Key::Quote, - KeyCode::Cut => Key::Cut, - KeyCode::Copy => Key::Copy, - KeyCode::Paste => Key::Paste, KeyCode::Minus | KeyCode::NumpadSubtract => Key::Minus, KeyCode::NumpadAdd => Key::Plus, KeyCode::Equal => Key::Equals, @@ -1321,7 +1323,7 @@ fn translate_cursor(cursor_icon: egui::CursorIcon) -> Option { - actions_requested.insert(ActionRequested::Screenshot); + ViewportCommand::Screenshot(user_data) => { + actions_requested.insert(ActionRequested::Screenshot(user_data)); } ViewportCommand::RequestCut => { actions_requested.insert(ActionRequested::Cut); From a34ea8fec6aaf0b753fec2a8ceeec8891558f148 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Thu, 5 Dec 2024 02:23:13 +0900 Subject: [PATCH 4/6] Update key.rs --- crates/egui/src/data/key.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/egui/src/data/key.rs b/crates/egui/src/data/key.rs index 75f9ed1b65d..dfb64c9f6f6 100644 --- a/crates/egui/src/data/key.rs +++ b/crates/egui/src/data/key.rs @@ -25,10 +25,6 @@ pub enum Key { PageUp, PageDown, - CapsLock, - NumLock, - ScrollLock, - Alt, AltRight, Control, @@ -36,6 +32,10 @@ pub enum Key { Shift, ShiftRight, + CapsLock, + NumLock, + ScrollLock, + Copy, Cut, Paste, @@ -66,7 +66,7 @@ pub enum Key { // `]` CloseBracket, - /// \`, also known as "backquote" or "grave" + /// Also known as "backquote" or "grave" Backtick, /// `-` @@ -212,15 +212,18 @@ impl Key { Self::End, Self::PageUp, Self::PageDown, - Self::CapsLock, - Self::NumLock, - Self::ScrollLock, + // Alt Ctrl Shift Self::Alt, Self::AltRight, Self::Control, Self::ControlRight, Self::Shift, Self::ShiftRight, + // Lock + Self::CapsLock, + Self::NumLock, + Self::ScrollLock, + // Copy Cut Paste Self::Copy, Self::Cut, Self::Paste, From 5a2110dc7a939800c3cc52ffe839cef5b0a94f26 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Thu, 5 Dec 2024 03:27:26 +0900 Subject: [PATCH 5/6] Update lib.rs --- crates/egui-winit/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 8307a9a00a8..2edde6939b1 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -1084,9 +1084,9 @@ fn key_from_named_key(named_key: winit::keyboard::NamedKey) -> Option NamedKey::Insert => Key::Insert, NamedKey::Escape => Key::Escape, - NamedKey::Alt => Key::Alt, - NamedKey::Control => Key::Control, - NamedKey::Shift => Key::Shift, + NamedKey::Alt => Key::AltLeft, + NamedKey::Control => Key::ControlLeft, + NamedKey::Shift => Key::ShiftLeft, NamedKey::CapsLock => Key::CapsLock, NamedKey::NumLock => Key::NumLock, @@ -1163,11 +1163,11 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option { KeyCode::PageUp => Key::PageUp, KeyCode::PageDown => Key::PageDown, - KeyCode::AltLeft => Key::Alt, + KeyCode::AltLeft => Key::AltLeft, KeyCode::AltRight => Key::AltRight, - KeyCode::ControlLeft => Key::Control, + KeyCode::ControlLeft => Key::ControlLeft, KeyCode::ControlRight => Key::ControlRight, - KeyCode::ShiftLeft => Key::Shift, + KeyCode::ShiftLeft => Key::ShiftLeft, KeyCode::ShiftRight => Key::ShiftRight, KeyCode::CapsLock => Key::CapsLock, From 7b3d7ad8f88600a1d9d53e7a672351e1dee0e040 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Thu, 5 Dec 2024 03:27:49 +0900 Subject: [PATCH 6/6] Update key.rs --- crates/egui/src/data/key.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/egui/src/data/key.rs b/crates/egui/src/data/key.rs index dfb64c9f6f6..71e1db4725c 100644 --- a/crates/egui/src/data/key.rs +++ b/crates/egui/src/data/key.rs @@ -25,11 +25,11 @@ pub enum Key { PageUp, PageDown, - Alt, + AltLeft, AltRight, - Control, + ControlLeft, ControlRight, - Shift, + ShiftLeft, ShiftRight, CapsLock, @@ -213,11 +213,11 @@ impl Key { Self::PageUp, Self::PageDown, // Alt Ctrl Shift - Self::Alt, + Self::AltLeft, Self::AltRight, - Self::Control, + Self::ControlLeft, Self::ControlRight, - Self::Shift, + Self::ShiftLeft, Self::ShiftRight, // Lock Self::CapsLock, @@ -352,11 +352,11 @@ impl Key { "NumLock" => Self::NumLock, "ScrollLock" => Self::ScrollLock, - "Alt" => Self::Alt, + "AltLeft" => Self::AltLeft, "AltRight" => Self::AltRight, - "Control" => Self::Control, + "ControlLeft" => Self::ControlLeft, "ControlRight" => Self::ControlRight, - "Shift" => Self::Shift, + "ShiftLeft" => Self::ShiftLeft, "ShiftRight" => Self::ShiftRight, "Copy" => Self::Copy, @@ -512,11 +512,11 @@ impl Key { Self::NumLock => "NumLock", Self::ScrollLock => "ScrollLock", - Self::Alt => "Alt", + Self::AltLeft => "AltLeft", Self::AltRight => "AltRight", - Self::Control => "Control", + Self::ControlLeft => "ControlLeft", Self::ControlRight => "ControlRight", - Self::Shift => "Shift", + Self::ShiftLeft => "ShiftLeft", Self::ShiftRight => "ShiftRight", Self::Copy => "Copy",