From 97e0683c77461e7f13ab40ff9bc6f8a56c7a9d7e Mon Sep 17 00:00:00 2001 From: jp Date: Tue, 15 Mar 2016 07:59:09 +0100 Subject: [PATCH] keyboard event handling --- OTKCrow/OpenTKGameWindow.cs | 7 +------ src/Interface.cs | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/OTKCrow/OpenTKGameWindow.cs b/OTKCrow/OpenTKGameWindow.cs index dc687b64..94a52a0c 100644 --- a/OTKCrow/OpenTKGameWindow.cs +++ b/OTKCrow/OpenTKGameWindow.cs @@ -317,15 +317,10 @@ namespace Crow #endregion #region keyboard Handling - KeyboardState Keyboad = new KeyboardState (); void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e) { -// if (_focusedWidget == null) { + if (!CrowInterface.ProcessKeyDown((int)otk_e.Key)) KeyboardKeyDown.Raise (this, otk_e); -// return; -// } - Keyboad.SetKeyState ((Crow.Key)otk_e.Key, true); - KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)otk_e.Key, otk_e.IsRepeat,Keyboad); } #endregion } diff --git a/src/Interface.cs b/src/Interface.cs index 1084ef7b..75310918 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -647,9 +647,22 @@ namespace Crow hoverWidget.onMouseWheel (this, e); return true; } -// public bool ProcessKeyDown(int Key){ -// -// } + public bool ProcessKeyDown(int Key){ + Keyboard.SetKeyState ((Crow.Key)Key, true); + if (_focusedWidget == null) + return false; + KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)Key, false, Keyboard); + _focusedWidget.onKeyDown (this, e); + return true; + } + public bool ProcessKeyUp(int Key){ + Keyboard.SetKeyState ((Crow.Key)Key, false); + if (_activeWidget == null) + return false; + //KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)Key, false, Keyboard); + return true; + } + volatile bool mouseRepeatOn; volatile int mouseRepeatCount; Thread mouseRepeatThread; -- 2.47.3