Application.Navigation.cs 4.2 KB

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