Application.Navigation.cs 4.1 KB

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