private void KeyPressed(object sender, KeyboardInput.KeyEventArgs e) { switch (e.KeyCode) { case Keys.Enter: EnterDown?.Invoke(this, e); break; case Keys.Left: if (KeyboardInput.CtrlDown) { //Move cursor ((Ctrl + Left) } else { //Cursor--; } break; case Keys.Right: if (KeyboardInput.CtrlDown) { //Move cursor ((Ctrl+Right)) } else { //Cursor--; } break; case Keys.Home: //Cursor = 0; break; case Keys.Delete: Text.Text = Text.Text.Remove(Text.Text.Length - 1, 1); break; case Keys.Back: if (Text.Text.Length > 0) { Text.Text = Text.Text.Remove(Text.Text.Length - 1, 1); } break; } }
private void KeyPressed(object sender, KeyboardInput.KeyEventArgs e, KeyboardState ks) { if (Active) { int oldPos = Cursor.TextCursor; switch (e.KeyCode) { case Keys.Enter: EnterDown?.Invoke(this, e); break; case Keys.Left: if (KeyboardInput.CtrlDown) { Cursor.TextCursor = IndexOfLastCharBeforeWhitespace(Cursor.TextCursor, Text.Characters); } else { Cursor.TextCursor--; } ShiftMod(oldPos); break; case Keys.Right: if (KeyboardInput.CtrlDown) { Cursor.TextCursor = IndexOfNextCharAfterWhitespace(Cursor.TextCursor, Text.Characters); } else { Cursor.TextCursor++; } ShiftMod(oldPos); break; case Keys.Home: Cursor.TextCursor = 0; ShiftMod(oldPos); break; case Keys.End: Cursor.TextCursor = Text.Length; ShiftMod(oldPos); break; case Keys.Delete: if (DelSelection() == null && Cursor.TextCursor < Text.Length) { Text.RemoveCharacters(Cursor.TextCursor, Cursor.TextCursor + 1); } break; case Keys.Back: if (DelSelection() == null && Cursor.TextCursor > 0) { Text.RemoveCharacters(Cursor.TextCursor - 1, Cursor.TextCursor); Cursor.TextCursor--; } break; case Keys.A: if (KeyboardInput.CtrlDown) { if (Text.Length > 0) { Cursor.SelectedChar = 0; Cursor.TextCursor = Text.Length; } } break; case Keys.C: if (KeyboardInput.CtrlDown) { clipboard = DelSelection(true); } break; case Keys.X: if (KeyboardInput.CtrlDown) { if (Cursor.SelectedChar.HasValue) { clipboard = DelSelection(); } } break; case Keys.V: if (KeyboardInput.CtrlDown) { if (clipboard != null) { DelSelection(); foreach (char c in clipboard) { if (Text.Length < Text.MaxLength) { Text.InsertCharacter(Cursor.TextCursor, c); Cursor.TextCursor++; } } } } break; } } }
private void OnEnterDown(object sender, GamePadEventArgs args) => EnterDown?.Invoke();
/// <summary> /// Вызывает событие нажатия клавиши Enter /// </summary> protected virtual void CallEnterDown() { EnterDown?.Invoke(this, EventArgs.Empty); }