From 13831792f33e8efa5f257f7e54b401c4e975df43 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 8 Sep 2015 14:29:17 +0300 Subject: [PATCH] Hack to get F12 working on Linux --- src/Gtk/Perspex.Gtk/Input/GtkKeyboardDevice.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Gtk/Perspex.Gtk/Input/GtkKeyboardDevice.cs b/src/Gtk/Perspex.Gtk/Input/GtkKeyboardDevice.cs index 662cb7695c..ea9b8691ab 100644 --- a/src/Gtk/Perspex.Gtk/Input/GtkKeyboardDevice.cs +++ b/src/Gtk/Perspex.Gtk/Input/GtkKeyboardDevice.cs @@ -7,15 +7,25 @@ namespace Perspex.Gtk { using System; + using System.Collections.Generic; + using System.Reflection; using Perspex.Input; - + public class GtkKeyboardDevice : KeyboardDevice { private static GtkKeyboardDevice instance; + private static readonly Dictionary NameDic = new Dictionary(); static GtkKeyboardDevice() { instance = new GtkKeyboardDevice(); + foreach (var f in typeof (Gdk.Key).GetFields(BindingFlags.Public | BindingFlags.Static)) + { + var key = (Gdk.Key) f.GetValue(null); + if(NameDic.ContainsKey(key)) + continue; + NameDic[key] = f.Name; + } } private GtkKeyboardDevice() @@ -36,7 +46,9 @@ namespace Perspex.Gtk } else { - var s = Enum.GetName(typeof(Gdk.Key), key); + string s; + if (!NameDic.TryGetValue(key, out s)) + s = "Unknown"; Perspex.Input.Key result; if (Enum.TryParse(s, true, out result))