private void HAndleKeyDown(object sender, InputKeyEventArgs e)
 {
     if (e.Key == Keys.Left)
     {
         if (CursorPos > 0)
         {
             CursorPos--;
         }
     }
     if (e.Key == Keys.Home)
     {
         CursorPos = 0;
     }
     if (e.Key == Keys.End)
     {
         CursorPos = InputText.Length;
     }
     if (e.Key == Keys.Right)
     {
         if (CursorPos < InputText.Length)
         {
             CursorPos++;
         }
     }
 }
Example #2
0
 private void Window_KeyDown(object sender, InputKeyEventArgs e)
 {
     if (_keyMappings.ContainsKey(e.Key))
     {
         _cpu.SetKeyDown(_keyMappings[e.Key]);
     }
 }
 private void Window_KeyDown(object sender, InputKeyEventArgs e)
 {
     if (!namelessGame.CurrentContext.Systems.Contains(this))
     {
         return;
     }
     lastState = Keyboard.GetState();
 }
        private void HandleKeyUp(object sender, InputKeyEventArgs e)
        {
            if (e.Key == ConsoleToggleKey)
            {
                IsConsoleOpen = !IsConsoleOpen;
            }

            if (IsConsoleOpen && e.Key == FullHeightToggle)
            {
                DevConsole.UseFullHeight = !DevConsole.UseFullHeight;
            }
        }
Example #5
0
        private void GameKeyUp(object sender, InputKeyEventArgs e)
        {
            var modifiers = GetModifiers();
            var ev        = new KeyEventArgs(e.Key, modifiers);

            // Handle system keys.
            switch (ev.Key)
            {
            // dev console
            case Keys.F1:
                if (GameLoop.DevConsole.IsOpen)
                {
                    GameLoop.DevConsole.Close();
                }
                else
                {
                    GameLoop.DevConsole.Open();
                }
                break;

            // Take Screenshot.
            case Keys.F2:
                GameLoop.TakeScreenshot();
                break;

                #if DEBUG
            // Developer: Toggle GUI hover highlight
            case Keys.F4:
                Settings.HighlightHoveredGuiElement = !Settings.HighlightHoveredGuiElement;
                break;
                #endif
            // Full-screen toggle.
            case Keys.F11:
                if (Settings.FullScreenMode == FullScreenMode.Windowed)
                {
                    Settings.FullScreenMode = FullScreenMode.FullScreen;
                }
                else
                {
                    Settings.FullScreenMode = FullScreenMode.Windowed;
                }
                break;

            // Dark theme toggle for the UI.
            case Keys.F12:
                Settings.EnableDarkTheme = !Settings.EnableDarkTheme;
                break;
            }

            KeyUp?.Invoke(this, ev);
        }
Example #6
0
 private void KeyHandler(object sender, InputKeyEventArgs args)
 {
     if (args.Key == Keys.Left)
     {
         cursorPos--;
         cursorPos = MathHelper.Clamp(cursorPos, -1, text.Length - 1);
     }
     if (args.Key == Keys.Right)
     {
         cursorPos++;
         cursorPos = MathHelper.Clamp(cursorPos, -1, text.Length - 1);
     }
     if (args.Key == Keys.Delete)
     {
         if (text.Length > 0 && cursorPos < text.Length - 1)
         {
             text = text.Remove(cursorPos + 1, 1);
             stringBuilder.Remove(cursorPos + 1, 1);
             modifiedText = true;
         }
     }
     if (args.Key == Keys.Up)
     {
         if (mulitpleLines)
         {
             cursorPos -= AmountToMoveOnLineChange();
             cursorPos  = MathHelper.Clamp(cursorPos, -1, text.Length - 1);
         }
         else
         {
             cursorPos = -1;
         }
     }
     if (args.Key == Keys.Down)
     {
         if (mulitpleLines)
         {
             cursorPos += AmountToMoveOnLineChange();
             cursorPos  = MathHelper.Clamp(cursorPos, -1, text.Length - 1);
         }
         else
         {
             cursorPos = text.Length - 1;
         }
     }
     timeSinceWritten.Restart();
     showingCursor = true;
 }
Example #7
0
        private void GameKeyDown(object sender, InputKeyEventArgs e)
        {
            var modifiers = GetModifiers();

            KeyDown?.Invoke(this, new KeyEventArgs(e.Key, modifiers));
        }
Example #8
0
 public void Window_KeyUp(object sender, InputKeyEventArgs e)
 {
     _lastKeyUp = (int)e.Key;
 }
Example #9
0
 public void Window_KeyDown(object sender, InputKeyEventArgs e)
 {
 }
Example #10
0
 public void SendKeyUp(object _, InputKeyEventArgs e)
 {
     OnKeyUp?.Invoke(e.Key);
 }