From 49902d2e286a6a6ff76d947e334ce4688e47cdd4 Mon Sep 17 00:00:00 2001 From: sy1ntexx Date: Sun, 22 May 2022 17:39:19 +0300 Subject: [PATCH 1/3] Added support for 20 fn keys --- eframe/src/web/input.rs | 21 +++++++++++++++++++++ egui-winit/src/lib.rs | 21 +++++++++++++++++++++ egui/src/data/input.rs | 20 ++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/eframe/src/web/input.rs b/eframe/src/web/input.rs index 388e2ca9439..80e8bdcfb3e 100644 --- a/eframe/src/web/input.rs +++ b/eframe/src/web/input.rs @@ -170,6 +170,27 @@ pub fn translate_key(key: &str) -> Option { "y" | "Y" => Some(egui::Key::Y), "z" | "Z" => Some(egui::Key::Z), + "F1" => Some(egui::Key::F1), + "F2" => Some(egui::Key::F2), + "F3" => Some(egui::Key::F3), + "F4" => Some(egui::Key::F4), + "F5" => Some(egui::Key::F5), + "F6" => Some(egui::Key::F6), + "F7" => Some(egui::Key::F7), + "F8" => Some(egui::Key::F8), + "F9" => Some(egui::Key::F9), + "F10" => Some(egui::Key::F10), + "F11" => Some(egui::Key::F11), + "F12" => Some(egui::Key::F12), + "F13" => Some(egui::Key::F13), + "F14" => Some(egui::Key::F14), + "F15" => Some(egui::Key::F15), + "F16" => Some(egui::Key::F16), + "F17" => Some(egui::Key::F17), + "F18" => Some(egui::Key::F18), + "F19" => Some(egui::Key::F19), + "F20" => Some(egui::Key::F20), + _ => None, } } diff --git a/egui-winit/src/lib.rs b/egui-winit/src/lib.rs index 497db28ad13..b534f7f95de 100644 --- a/egui-winit/src/lib.rs +++ b/egui-winit/src/lib.rs @@ -628,6 +628,27 @@ fn translate_virtual_key_code(key: winit::event::VirtualKeyCode) -> Option Key::Y, VirtualKeyCode::Z => Key::Z, + VirtualKeyCode::F1 => Key::F1, + VirtualKeyCode::F2 => Key::F2, + VirtualKeyCode::F3 => Key::F3, + VirtualKeyCode::F4 => Key::F4, + VirtualKeyCode::F5 => Key::F5, + VirtualKeyCode::F6 => Key::F6, + VirtualKeyCode::F7 => Key::F7, + VirtualKeyCode::F8 => Key::F8, + VirtualKeyCode::F9 => Key::F9, + VirtualKeyCode::F10 => Key::F10, + VirtualKeyCode::F11 => Key::F11, + VirtualKeyCode::F12 => Key::F12, + VirtualKeyCode::F13 => Key::F13, + VirtualKeyCode::F14 => Key::F14, + VirtualKeyCode::F15 => Key::F15, + VirtualKeyCode::F16 => Key::F16, + VirtualKeyCode::F17 => Key::F17, + VirtualKeyCode::F18 => Key::F18, + VirtualKeyCode::F19 => Key::F19, + VirtualKeyCode::F20 => Key::F20, + _ => { return None; } diff --git a/egui/src/data/input.rs b/egui/src/data/input.rs index adfa7db9578..84c68d27a51 100644 --- a/egui/src/data/input.rs +++ b/egui/src/data/input.rs @@ -498,6 +498,26 @@ pub enum Key { X, Y, Z, // Used for cmd+Z (undo) + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + F16, + F17, + F18, + F19, + F20, } impl RawInput { From 058dc952c5c30e9bf6fdba25eef563e1e119265e Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 23 May 2022 17:12:27 +0200 Subject: [PATCH 2/3] Add some spacing --- egui/src/data/input.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/egui/src/data/input.rs b/egui/src/data/input.rs index 84c68d27a51..2b04f60453c 100644 --- a/egui/src/data/input.rs +++ b/egui/src/data/input.rs @@ -498,6 +498,8 @@ pub enum Key { X, Y, Z, // Used for cmd+Z (undo) + + // The function keys: F1, F2, F3, From ea8ed3d5a63a6959bf7a42e0fa1b94b992ab977e Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 23 May 2022 17:23:13 +0200 Subject: [PATCH 3/3] cargo fmt --- egui/src/data/input.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egui/src/data/input.rs b/egui/src/data/input.rs index 2b04f60453c..75eaca29d94 100644 --- a/egui/src/data/input.rs +++ b/egui/src/data/input.rs @@ -498,7 +498,7 @@ pub enum Key { X, Y, Z, // Used for cmd+Z (undo) - + // The function keys: F1, F2,