]> O.S.I.I.S - jp/crow.git/commitdiff
keyboard event handling
authorjp <jp_bruyere@hotmail.com>
Tue, 15 Mar 2016 06:59:09 +0000 (07:59 +0100)
committerjp <jp_bruyere@hotmail.com>
Tue, 15 Mar 2016 06:59:09 +0000 (07:59 +0100)
OTKCrow/OpenTKGameWindow.cs
src/Interface.cs

index dc687b6465726ad7ce308f4d53f8ad621e1f6d5d..94a52a0c6d014f3ebdd90f91786ecfea6f1a8f42 100644 (file)
@@ -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
     }
index 1084ef7b54d35aee19ddc1188461ad198d60568b..7531091851a3ae431a7c4f0c4eab499c305cb12b 100644 (file)
@@ -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;