Application.Keyboard.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. namespace Terminal.Gui.App;
  2. public static partial class Application // Keyboard handling
  3. {
  4. /// <inheritdoc cref="IApplication.Keyboard"/>
  5. [Obsolete ("The legacy static Application object is going away.")]
  6. public static IKeyboard Keyboard
  7. {
  8. get => ApplicationImpl.Instance.Keyboard;
  9. set => ApplicationImpl.Instance.Keyboard = value ??
  10. throw new ArgumentNullException(nameof(value));
  11. }
  12. /// <inheritdoc cref="IKeyboard.RaiseKeyDownEvent"/>
  13. [Obsolete ("The legacy static Application object is going away.")]
  14. public static bool RaiseKeyDownEvent (Key key) => ApplicationImpl.Instance.Keyboard.RaiseKeyDownEvent (key);
  15. /// <summary>
  16. /// Raised when the user presses a key.
  17. /// <para>
  18. /// Set <see cref="Key.Handled"/> to <see langword="true"/> to indicate the key was handled and to prevent
  19. /// additional processing.
  20. /// </para>
  21. /// </summary>
  22. /// <remarks>
  23. /// All drivers support firing the <see cref="KeyDown"/> event. Some drivers (Unix) do not support firing the
  24. /// <see cref="KeyDown"/> and <see cref="KeyUp"/> events.
  25. /// <para>Fired after <see cref="KeyDown"/> and before <see cref="KeyUp"/>.</para>
  26. /// </remarks>
  27. [Obsolete ("The legacy static Application object is going away.")]
  28. public static event EventHandler<Key>? KeyDown
  29. {
  30. add => ApplicationImpl.Instance.Keyboard.KeyDown += value;
  31. remove => ApplicationImpl.Instance.Keyboard.KeyDown -= value;
  32. }
  33. /// <inheritdoc cref="IKeyboard.KeyBindings"/>
  34. [Obsolete ("The legacy static Application object is going away.")]
  35. public static KeyBindings KeyBindings => ApplicationImpl.Instance.Keyboard.KeyBindings;
  36. }