Browse Source

Hack to get F12 working on Linux

pull/131/head
Nikita Tsukanov 11 years ago
parent
commit
13831792f3
  1. 16
      src/Gtk/Perspex.Gtk/Input/GtkKeyboardDevice.cs

16
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<Gdk.Key, string> NameDic = new Dictionary<Gdk.Key, string>();
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))

Loading…
Cancel
Save