Application.Navigation.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #nullable enable
  2. namespace Terminal.Gui;
  3. public static partial class Application // Navigation stuff
  4. {
  5. /// <summary>
  6. /// Gets the <see cref="ApplicationNavigation"/> instance for the current <see cref="Application"/>.
  7. /// </summary>
  8. public static ApplicationNavigation? Navigation { get; internal set; }
  9. private static Key _nextTabGroupKey = Key.F6; // Resources/config.json overrides
  10. private static Key _nextTabKey = Key.Tab; // Resources/config.json overrides
  11. private static Key _prevTabGroupKey = Key.F6.WithShift; // Resources/config.json overrides
  12. private static Key _prevTabKey = Key.Tab.WithShift; // Resources/config.json overrides
  13. /// <summary>Alternative key to navigate forwards through views. Ctrl+Tab is the primary key.</summary>
  14. [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
  15. public static Key NextTabGroupKey
  16. {
  17. get => _nextTabGroupKey;
  18. set
  19. {
  20. if (_nextTabGroupKey != value)
  21. {
  22. KeyBindings.ReplaceKey (_nextTabGroupKey, value);
  23. _nextTabGroupKey = value;
  24. }
  25. }
  26. }
  27. /// <summary>Alternative key to navigate forwards through views. Ctrl+Tab is the primary key.</summary>
  28. [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
  29. public static Key NextTabKey
  30. {
  31. get => _nextTabKey;
  32. set
  33. {
  34. if (_nextTabKey != value)
  35. {
  36. KeyBindings.ReplaceKey (_nextTabKey, value);
  37. _nextTabKey = value;
  38. }
  39. }
  40. }
  41. /// <summary>
  42. /// Raised when the user releases a key.
  43. /// <para>
  44. /// Set <see cref="Key.Handled"/> to <see langword="true"/> to indicate the key was handled and to prevent
  45. /// additional processing.
  46. /// </para>
  47. /// </summary>
  48. /// <remarks>
  49. /// All drivers support firing the <see cref="KeyDown"/> event. Some drivers (Curses) do not support firing the
  50. /// <see cref="KeyDown"/> and <see cref="KeyUp"/> events.
  51. /// <para>Fired after <see cref="KeyDown"/>.</para>
  52. /// </remarks>
  53. public static event EventHandler<Key>? KeyUp;
  54. /// <summary>Alternative key to navigate backwards through views. Shift+Ctrl+Tab is the primary key.</summary>
  55. [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
  56. public static Key PrevTabGroupKey
  57. {
  58. get => _prevTabGroupKey;
  59. set
  60. {
  61. if (_prevTabGroupKey != value)
  62. {
  63. KeyBindings.ReplaceKey (_prevTabGroupKey, value);
  64. _prevTabGroupKey = value;
  65. }
  66. }
  67. }
  68. /// <summary>Alternative key to navigate backwards through views. Shift+Ctrl+Tab is the primary key.</summary>
  69. [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
  70. public static Key PrevTabKey
  71. {
  72. get => _prevTabKey;
  73. set
  74. {
  75. if (_prevTabKey != value)
  76. {
  77. KeyBindings.ReplaceKey (_prevTabKey, value);
  78. _prevTabKey = value;
  79. }
  80. }
  81. }
  82. }