Browse Source

Fixed adornment editor scenarios

Tig 11 tháng trước cách đây
mục cha
commit
20249faa10
33 tập tin đã thay đổi với 248 bổ sung323 xóa
  1. 1 0
      .github/workflows/publish.yml
  2. 7 3
      Terminal.Gui/Application/Application.Run.cs
  3. 2 2
      Terminal.Gui/Application/ApplicationOverlapped.cs
  4. 1 0
      Terminal.Gui/Application/MainLoop.cs
  5. 1 0
      Terminal.Gui/Input/Responder.cs
  6. 4 1
      Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs
  7. 1 0
      Terminal.Gui/Text/CollectionNavigatorBase.cs
  8. 1 1
      Terminal.Gui/View/Adornment/Adornment.cs
  9. 2 2
      Terminal.Gui/View/Orientation/IOrientation.cs
  10. 1 0
      Terminal.Gui/View/View.Adornments.cs
  11. 2 3
      Terminal.Gui/View/View.Content.cs
  12. 2 0
      Terminal.Gui/View/View.Drawing.cs
  13. 5 5
      Terminal.Gui/View/View.Hierarchy.cs
  14. 5 5
      Terminal.Gui/View/View.Keyboard.cs
  15. 6 6
      Terminal.Gui/View/View.Layout.cs
  16. 12 12
      Terminal.Gui/View/View.Navigation.cs
  17. 1 1
      Terminal.Gui/View/View.Text.cs
  18. 16 14
      Terminal.Gui/View/View.cs
  19. 7 6
      Terminal.Gui/Views/Bar.cs
  20. 1 1
      Terminal.Gui/Views/ColorPicker.cs
  21. 1 0
      Terminal.Gui/Views/ColorPicker16.cs
  22. 3 0
      Terminal.Gui/Views/TextField.cs
  23. 3 0
      Terminal.Gui/Views/TextView.cs
  24. 2 1
      UICatalog/Scenarios/AdornmentEditor.cs
  25. 3 26
      UICatalog/Scenarios/Adornments.cs
  26. 87 16
      UICatalog/Scenarios/AdornmentsEditor.cs
  27. 22 15
      UICatalog/Scenarios/AllViewsTester.cs
  28. 3 26
      UICatalog/Scenarios/ContentScrolling.cs
  29. 34 37
      UICatalog/Scenarios/Navigation.cs
  30. 5 6
      UICatalog/Scenarios/NumericUpDownDemo.cs
  31. 1 1
      UICatalog/Scenarios/ProgressBarStyles.cs
  32. 3 25
      UICatalog/Scenarios/ShadowStyles.cs
  33. 3 108
      UICatalog/Scenarios/ViewExperiments.cs

+ 1 - 0
.github/workflows/publish.yml

@@ -44,6 +44,7 @@ jobs:
       run: |
         dotnet-gitversion /updateprojectfiles
         dotnet build --no-incremental --nologo --force --configuration Release
+        dotnet test --configuration Release
 
     - name: Pack
       run: dotnet pack -c Release --include-symbols -p:Version='${{ steps.gitversion.outputs.SemVer }}' 

+ 7 - 3
Terminal.Gui/Application/Application.Run.cs

@@ -189,11 +189,15 @@ public static partial class Application // Run (Begin, Run, End, Stop)
 
         // TODO: Should this use FindDeepestFocusableView instead?
         // Try to set initial focus to any TabStop
-        if (!toplevel.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop))
+        if (!toplevel.HasFocus)
         {
-            // That didn't work. Try TabGroup.
-            toplevel.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabGroup);
+            if (!toplevel.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabStop))
+            {
+                // That didn't work. Try TabGroup.
+                toplevel.AdvanceFocus (NavigationDirection.Forward, TabBehavior.TabGroup);
+            }
         }
+
         ApplicationOverlapped.BringOverlappedTopToFront ();
 
         if (refreshDriver)

+ 2 - 2
Terminal.Gui/Application/ApplicationOverlapped.cs

@@ -96,12 +96,12 @@ public static class ApplicationOverlapped
 
         foreach (Toplevel top in OverlappedChildren)
         {
-            if (type is { } && top.GetType () == type && exclude?.Contains (top.Data.ToString ()) == false)
+            if (type is { } && top.GetType () == type && exclude?.Contains (top.Data?.ToString ()) == false)
             {
                 return top;
             }
 
-            if ((type is { } && top.GetType () != type) || exclude?.Contains (top.Data.ToString ()) == true)
+            if ((type is { } && top.GetType () != type) || exclude?.Contains (top.Data?.ToString ()) == true)
             {
                 continue;
             }

+ 1 - 0
Terminal.Gui/Application/MainLoop.cs

@@ -296,6 +296,7 @@ internal class MainLoop : IDisposable
     ///     Invoked when a new timeout is added. To be used in the case when
     ///     <see cref="Application.EndAfterFirstIteration"/> is <see langword="true"/>.
     /// </summary>
+    [CanBeNull]
     internal event EventHandler<TimeoutEventArgs> TimeoutAdded;
 
     /// <summary>Wakes up the <see cref="MainLoop"/> that might be waiting on input.</summary>

+ 1 - 0
Terminal.Gui/Input/Responder.cs

@@ -26,6 +26,7 @@ public class Responder : IDisposable
     }
 
     /// <summary>Event raised when <see cref="Dispose()"/> has been called to signal that this object is being disposed.</summary>
+    [CanBeNull]
     public event EventHandler Disposing;
 
     /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>

+ 4 - 1
Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs

@@ -535,7 +535,10 @@ public abstract partial class PopupAutocomplete : AutocompleteBase
     {
         if (_popup is null)
         {
-            _popup = new Popup (this) { Frame = Rectangle.Empty };
+            _popup = new Popup (this)
+            {
+                CanFocus = false
+            };
             _top?.Add (_popup);
         }
     }

+ 1 - 0
Terminal.Gui/Text/CollectionNavigatorBase.cs

@@ -147,6 +147,7 @@ public abstract class CollectionNavigatorBase
     public virtual void OnSearchStringChanged (KeystrokeNavigatorEventArgs e) { SearchStringChanged?.Invoke (this, e); }
 
     /// <summary>This event is invoked when <see cref="SearchString"/>  changes. Useful for debugging.</summary>
+    [CanBeNull]
     public event EventHandler<KeystrokeNavigatorEventArgs> SearchStringChanged;
 
     /// <summary>Returns the collection being navigated element at <paramref name="idx"/>.</summary>

+ 1 - 1
Terminal.Gui/View/Adornment/Adornment.cs

@@ -86,7 +86,7 @@ public class Adornment : View
     ///     Adornments cannot be used as sub-views (see <see cref="Parent"/>); setting this property will throw
     ///     <see cref="InvalidOperationException"/>.
     /// </summary>
-    public override View SuperView
+    public override View? SuperView
     {
         get => null!;
         set => throw new InvalidOperationException (@"Adornments can not be Subviews or have SuperViews. Use Parent instead.");

+ 2 - 2
Terminal.Gui/View/Orientation/IOrientation.cs

@@ -19,7 +19,7 @@ public interface IOrientation
     /// <summary>
     ///     Raised when <see cref="Orientation"/> is changing. Can be cancelled.
     /// </summary>
-    public event EventHandler<CancelEventArgs<Orientation>> OrientationChanging;
+    public event EventHandler<CancelEventArgs<Orientation>>? OrientationChanging;
 
     /// <summary>
     ///     Called when <see cref="Orientation"/> is changing.
@@ -32,7 +32,7 @@ public interface IOrientation
     /// <summary>
     ///     Raised when <see cref="Orientation"/> has changed.
     /// </summary>
-    public event EventHandler<EventArgs<Orientation>> OrientationChanged;
+    public event EventHandler<EventArgs<Orientation>>? OrientationChanged;
 
     /// <summary>
     ///     Called when <see cref="Orientation"/> has been changed.

+ 1 - 0
Terminal.Gui/View/View.Adornments.cs

@@ -194,6 +194,7 @@ public partial class View // Adornments
     /// <summary>
     ///     Fired when the <see cref="BorderStyle"/> is changing. Allows the event to be cancelled.
     /// </summary>
+    [CanBeNull]
     public event EventHandler<CancelEventArgs<LineStyle>> BorderStyleChanging;
 
     /// <summary>

+ 2 - 3
Terminal.Gui/View/View.Content.cs

@@ -154,7 +154,7 @@ public partial class View
     /// <summary>
     ///     Event raised when the <see cref="GetContentSize ()"/> changes.
     /// </summary>
-    public event EventHandler<SizeChangedEventArgs> ContentSizeChanged;
+    public event EventHandler<SizeChangedEventArgs>? ContentSizeChanged;
 
     /// <summary>
     ///     Converts a Content-relative location to a Screen-relative location.
@@ -357,8 +357,7 @@ public partial class View
     ///     Fired when the <see cref="Viewport"/> changes. This event is fired after the <see cref="Viewport"/> has been
     ///     updated.
     /// </summary>
-    [CanBeNull]
-    public event EventHandler<DrawEventArgs> ViewportChanged;
+    public event EventHandler<DrawEventArgs>? ViewportChanged;
 
     /// <summary>
     ///     Called when the <see cref="Viewport"/> changes. Invokes the <see cref="ViewportChanged"/> event.

+ 2 - 0
Terminal.Gui/View/View.Drawing.cs

@@ -262,6 +262,7 @@ public partial class View // Drawing APIs
     ///         <see cref="View"/> .
     ///     </para>
     /// </remarks>
+    [CanBeNull]
     public event EventHandler<DrawEventArgs> DrawContent;
 
     /// <summary>Event invoked when the content area of the View is completed drawing.</summary>
@@ -272,6 +273,7 @@ public partial class View // Drawing APIs
     ///         <see cref="View"/> .
     ///     </para>
     /// </remarks>
+    [CanBeNull]
     public event EventHandler<DrawEventArgs> DrawContentComplete;
 
     /// <summary>Utility function to draw strings that contain a hotkey.</summary>

+ 5 - 5
Terminal.Gui/View/View.Hierarchy.cs

@@ -18,7 +18,7 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
 
     /// <summary>Returns the container for this view, or null if this view has not been added to a container.</summary>
     /// <value>The super view.</value>
-    public virtual View SuperView
+    public virtual View? SuperView
     {
         get => _superView!;
         set => throw new NotImplementedException ();
@@ -52,7 +52,7 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
         _subviews.Add (view);
         view._superView = this;
 
-        if (view.Enabled && view.Visible && view.CanFocus)
+        if (view is { Enabled: true, Visible: true, CanFocus: true })
         {
             // Add will cause the newly added subview to gain focus if it's focusable
             if (HasFocus)
@@ -94,7 +94,7 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
     ///         the lifecycle of the subviews to be transferred to this View.
     ///     </para>
     /// </remarks>
-    public void Add (params View [] views)
+    public void Add (params View []? views)
     {
         if (views is null)
         {
@@ -108,7 +108,7 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
     }
 
     /// <summary>Event fired when this view is added to another.</summary>
-    public event EventHandler<SuperViewChangedEventArgs> Added;
+    public event EventHandler<SuperViewChangedEventArgs>? Added;
 
     /// <summary>Get the top superview of a given <see cref="View"/>.</summary>
     /// <returns>The superview view.</returns>
@@ -222,7 +222,7 @@ public partial class View // SuperView/SubView hierarchy management (SuperView,
     }
 
     /// <summary>Event fired when this view is removed from another.</summary>
-    public event EventHandler<SuperViewChangedEventArgs> Removed;
+    public event EventHandler<SuperViewChangedEventArgs>? Removed;
 
 
     /// <summary>

+ 5 - 5
Terminal.Gui/View/View.Keyboard.cs

@@ -48,7 +48,7 @@ public partial class View  // Keyboard APIs
     }
 
     /// <summary>Invoked when the <see cref="HotKey"/> is changed.</summary>
-    public event EventHandler<KeyChangedEventArgs> HotKeyChanged;
+    public event EventHandler<KeyChangedEventArgs>? HotKeyChanged;
 
     private Key _hotKey = new ();
     private void TitleTextFormatter_HotKeyChanged (object? sender, KeyChangedEventArgs e) { HotKeyChanged?.Invoke (this, e); }
@@ -364,7 +364,7 @@ public partial class View  // Keyboard APIs
     ///     </para>
     ///     <para>See <see href="../docs/keyboard.md">for an overview of Terminal.Gui keyboard APIs.</see></para>
     /// </remarks>
-    public event EventHandler<Key> KeyDown;
+    public event EventHandler<Key>? KeyDown;
 
     /// <summary>
     ///     Low-level API called when the user presses a key, allowing views do things during key down events. This is
@@ -412,7 +412,7 @@ public partial class View  // Keyboard APIs
     ///     </para>
     ///     <para>See <see href="../docs/keyboard.md">for an overview of Terminal.Gui keyboard APIs.</see></para>
     /// </remarks>
-    public event EventHandler<Key> ProcessKeyDown;
+    public event EventHandler<Key>? ProcessKeyDown;
 
     #endregion KeyDown Event
 
@@ -503,7 +503,7 @@ public partial class View  // Keyboard APIs
     ///         <para>See <see href="../docs/keyboard.md">for an overview of Terminal.Gui keyboard APIs.</see></para>
     ///     </remarks>
     /// </summary>
-    public event EventHandler<Key> KeyUp;
+    public event EventHandler<Key>? KeyUp;
 
     #endregion KeyUp Event
 
@@ -512,7 +512,7 @@ public partial class View  // Keyboard APIs
     #region Key Bindings
 
     /// <summary>Gets the key bindings for this view.</summary>
-    public KeyBindings KeyBindings { get; internal set; }
+    public KeyBindings KeyBindings { get; internal set; } = null!;
 
     private Dictionary<Command, Func<CommandContext, bool?>> CommandImplementations { get; } = new ();
 

+ 6 - 6
Terminal.Gui/View/View.Layout.cs

@@ -163,7 +163,7 @@ public partial class View // Layout APIs
         }
         else
         {
-            View t = viewToMove!.SuperView;
+            View? t = viewToMove!.SuperView;
 
             while (t is { } and not Toplevel)
             {
@@ -194,7 +194,7 @@ public partial class View // Layout APIs
         }
         else
         {
-            View t = viewToMove!.SuperView;
+            View? t = viewToMove!.SuperView;
 
             while (t is { } and not Toplevel)
             {
@@ -311,7 +311,7 @@ public partial class View // Layout APIs
     public virtual Rectangle FrameToScreen ()
     {
         Rectangle screen = Frame;
-        View current = SuperView;
+        View? current = SuperView;
 
         while (current is { })
         {
@@ -547,14 +547,14 @@ public partial class View // Layout APIs
     ///     Subscribe to this event to perform tasks when the <see cref="View"/> has been resized or the layout has
     ///     otherwise changed.
     /// </remarks>
-    public event EventHandler<LayoutEventArgs> LayoutComplete;
+    public event EventHandler<LayoutEventArgs>? LayoutComplete;
 
     /// <summary>Fired after the View's <see cref="LayoutSubviews"/> method has completed.</summary>
     /// <remarks>
     ///     Subscribe to this event to perform tasks when the <see cref="View"/> has been resized or the layout has
     ///     otherwise changed.
     /// </remarks>
-    public event EventHandler<LayoutEventArgs> LayoutStarted;
+    public event EventHandler<LayoutEventArgs>? LayoutStarted;
 
     /// <summary>
     ///     Adjusts <see cref="Frame"/> given the SuperView's ContentSize (nominally the same as
@@ -694,7 +694,7 @@ public partial class View // Layout APIs
         HashSet<View> nodes = new ();
         HashSet<(View, View)> edges = new ();
         CollectAll (this, ref nodes, ref edges);
-        List<View> ordered = TopologicalSort (SuperView, nodes, edges);
+        List<View> ordered = TopologicalSort (SuperView!, nodes, edges);
 
         foreach (View v in ordered)
         {

+ 12 - 12
Terminal.Gui/View/View.Navigation.cs

@@ -152,7 +152,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
     /// <remarks>
     ///     Raised by the <see cref="OnCanFocusChanged"/> virtual method.
     /// </remarks>
-    public event EventHandler CanFocusChanged;
+    public event EventHandler? CanFocusChanged;
 
     /// <summary>
     ///     Focuses the deepest focusable Subview if one exists. If there are no focusable Subviews then the focus is set to the view itself.
@@ -485,15 +485,15 @@ public partial class View // Focus and cross-view navigation management (TabStop
     ///         Use <see cref="HasFocusChanged"/> to be notified after the focus has changed.
     ///     </para>
     /// </remarks>
-    public event EventHandler<HasFocusEventArgs> HasFocusChanging;
+    public event EventHandler<HasFocusEventArgs>? HasFocusChanging;
 
     /// <summary>
     ///     Called when this view should stop being focused.
     /// </summary>
-    /// <param name="newFocusedVew">The new focused view. If <see langword="null"/> it is not known which view will be focused.</param>
+    /// <param name="newFocusedView">The new focused view. If <see langword="null"/> it is not known which view will be focused.</param>
     /// <param name="traversingDown">Set to true to indicate method is being called recurively, traversing down the focus chain.</param>
     /// <exception cref="InvalidOperationException"></exception>
-    private void SetHasFocusFalse (View? newFocusedVew, bool traversingDown = false)
+    private void SetHasFocusFalse (View? newFocusedView, bool traversingDown = false)
     {
         // Pre-conditions
         if (!_hasFocus)
@@ -502,7 +502,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
         }
 
         // If newFocusedVew is null, we need to find the view that should get focus, and SetFocus on it.
-        if (!traversingDown && newFocusedVew is null)
+        if (!traversingDown && newFocusedView is null)
         {
             if (SuperView?._previouslyMostFocused is { } && SuperView?._previouslyMostFocused != this)
             {
@@ -539,16 +539,16 @@ public partial class View // Focus and cross-view navigation management (TabStop
         // Before we can leave focus, we need to make sure that all views down the subview-hierarchy have left focus.
         View? mostFocused = MostFocused;
 
-        if (mostFocused is { } && (newFocusedVew is null || mostFocused != newFocusedVew))
+        if (mostFocused is { } && (newFocusedView is null || mostFocused != newFocusedView))
         {
             // Start at the bottom and work our way up to us
-            View bottom = mostFocused;
+            View? bottom = mostFocused;
 
             while (bottom is { } && bottom != this)
             {
                 if (bottom.HasFocus)
                 {
-                    bottom.SetHasFocusFalse (newFocusedVew, true);
+                    bottom.SetHasFocusFalse (newFocusedView, true);
                 }
 
                 bottom = bottom.SuperView;
@@ -560,7 +560,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
         bool previousValue = HasFocus;
 
         // Note, can't be cancelled.
-        NotifyFocusChanging (HasFocus, !HasFocus, newFocusedVew, this);
+        NotifyFocusChanging (HasFocus, !HasFocus, newFocusedView, this);
 
         // Get whatever peer has focus, if any
         View? focusedPeer = SuperView?.Focused;
@@ -572,11 +572,11 @@ public partial class View // Focus and cross-view navigation management (TabStop
 
             if (appFocused is { } || appFocused == this)
             {
-                Application.Navigation.SetFocused (SuperView);
+               Application.Navigation.SetFocused (newFocusedView ?? SuperView);
             }
         }
 
-        NotifyFocusChanged (HasFocus, this, newFocusedVew);
+        NotifyFocusChanged (HasFocus, this, newFocusedView);
 
         if (_hasFocus)
         {
@@ -633,7 +633,7 @@ public partial class View // Focus and cross-view navigation management (TabStop
     ///         This event cannot be cancelled.
     ///     </para>
     /// </remarks>
-    public event EventHandler<HasFocusEventArgs> HasFocusChanged;
+    public event EventHandler<HasFocusEventArgs>? HasFocusChanged;
 
     #endregion HasFocus
 

+ 1 - 1
Terminal.Gui/View/View.Text.cs

@@ -4,7 +4,7 @@ namespace Terminal.Gui;
 
 public partial class View // Text Property APIs
 {
-    private string _text;
+    private string _text = null!;
 
     /// <summary>
     ///     Called when the <see cref="Text"/> has changed. Fires the <see cref="TextChanged"/> event.

+ 16 - 14
Terminal.Gui/View/View.cs

@@ -1,4 +1,5 @@
-using System.ComponentModel;
+#nullable enable
+using System.ComponentModel;
 using System.Diagnostics;
 
 namespace Terminal.Gui;
@@ -112,11 +113,11 @@ public partial class View : Responder, ISupportInitializeNotification
     ///     <see cref="HandledEventArgs.Handled"/>
     ///     to cancel the event.
     /// </summary>
-    public event EventHandler<HandledEventArgs> Accept;
+    public event EventHandler<HandledEventArgs>? Accept;
 
     /// <summary>Gets or sets arbitrary data for the view.</summary>
     /// <remarks>This property is not used internally.</remarks>
-    public object Data { get; set; }
+    public object? Data { get; set; }
 
     /// <summary>Gets or sets an identifier for the view;</summary>
     /// <value>The identifier.</value>
@@ -168,7 +169,7 @@ public partial class View : Responder, ISupportInitializeNotification
     ///     Points to the current driver in use by the view, it is a convenience property for simplifying the development
     ///     of new views.
     /// </summary>
-    public static ConsoleDriver Driver => Application.Driver;
+    public static ConsoleDriver Driver => Application.Driver!;
 
     /// <summary>Initializes a new instance of <see cref="View"/>.</summary>
     /// <remarks>
@@ -191,7 +192,7 @@ public partial class View : Responder, ISupportInitializeNotification
     ///     configurations and assignments to be performed before the <see cref="View"/> being shown.
     ///     View implements <see cref="ISupportInitializeNotification"/> to allow for more sophisticated initialization.
     /// </summary>
-    public event EventHandler Initialized;
+    public event EventHandler? Initialized;
 
     /// <summary>
     ///     Get or sets if  the <see cref="View"/> has been initialized (via <see cref="ISupportInitialize.BeginInit"/>
@@ -313,7 +314,8 @@ public partial class View : Responder, ISupportInitializeNotification
                 HasFocus = false;
             }
 
-            if (_enabled && CanFocus && Visible && !HasFocus && SuperView is { } && SuperView?.Focused is null)
+            if (_enabled && CanFocus && Visible && !HasFocus
+                && SuperView is null or { HasFocus: true, Visible: true, Enabled: true, Focused: null })
             {
                 SetFocus ();
             }
@@ -345,7 +347,7 @@ public partial class View : Responder, ISupportInitializeNotification
     }
 
     /// <summary>Event fired when the <see cref="Enabled"/> value is being changed.</summary>
-    public event EventHandler EnabledChanged;
+    public event EventHandler? EnabledChanged;
 
     /// <summary>Method invoked when the <see cref="Enabled"/> property from a view is changed.</summary>
     public virtual void OnEnabledChanged () { EnabledChanged?.Invoke (this, EventArgs.Empty); }
@@ -377,8 +379,8 @@ public partial class View : Responder, ISupportInitializeNotification
                 }
             }
 
-            if (_visible && CanFocus && Enabled && !HasFocus 
-                && (SuperView is null || SuperView is { HasFocus: true, Visible: true, Enabled: true, Focused: null }))
+            if (_visible && CanFocus && Enabled && !HasFocus
+                && SuperView is null or { HasFocus: true, Visible: true, Enabled: true, Focused: null })
             {
                 SetFocus ();
             }
@@ -395,7 +397,7 @@ public partial class View : Responder, ISupportInitializeNotification
     public bool ClearOnVisibleFalse { get; set; } = true;
 
     /// <summary>Event fired when the <see cref="Visible"/> value is being changed.</summary>
-    public event EventHandler VisibleChanged;
+    public event EventHandler? VisibleChanged;
 
     /// <summary>
     /// INTERNAL method for determining if all the specified view and all views up the Superview hierarchy are visible.
@@ -409,7 +411,7 @@ public partial class View : Responder, ISupportInitializeNotification
             return false;
         }
 
-        for (View c = view.SuperView; c != null; c = c.SuperView)
+        for (View? c = view.SuperView; c != null; c = c.SuperView)
         {
             if (!c.Visible)
             {
@@ -483,7 +485,7 @@ public partial class View : Responder, ISupportInitializeNotification
                 SetHotKeyFromTitle ();
                 SetNeedsDisplay ();
 #if DEBUG
-                if (_title is { } && string.IsNullOrEmpty (Id))
+                if (string.IsNullOrEmpty (Id))
                 {
                     Id = _title;
                 }
@@ -524,13 +526,13 @@ public partial class View : Responder, ISupportInitializeNotification
     }
 
     /// <summary>Event fired after the <see cref="View.Title"/> has been changed.</summary>
-    public event EventHandler<EventArgs<string>> TitleChanged;
+    public event EventHandler<EventArgs<string>>? TitleChanged;
 
     /// <summary>
     ///     Event fired when the <see cref="View.Title"/> is changing. Set <see cref="CancelEventArgs.Cancel"/> to `true`
     ///     to cancel the Title change.
     /// </summary>
-    public event EventHandler<CancelEventArgs<string>> TitleChanging;
+    public event EventHandler<CancelEventArgs<string>>? TitleChanging;
 
     #endregion
 }

+ 7 - 6
Terminal.Gui/Views/Bar.cs

@@ -1,3 +1,4 @@
+#nullable enable
 namespace Terminal.Gui;
 
 /// <summary>
@@ -43,7 +44,7 @@ public class Bar : View, IOrientation, IDesignable
         }
     }
 
-    private void Bar_Initialized (object sender, EventArgs e) { ColorScheme = Colors.ColorSchemes ["Menu"]; }
+    private void Bar_Initialized (object? sender, EventArgs e) { ColorScheme = Colors.ColorSchemes ["Menu"]; }
 
     /// <inheritdoc/>
     public override void SetBorderStyle (LineStyle value)
@@ -72,10 +73,10 @@ public class Bar : View, IOrientation, IDesignable
     }
 
     /// <inheritdoc/>
-    public event EventHandler<CancelEventArgs<Orientation>> OrientationChanging;
+    public event EventHandler<CancelEventArgs<Orientation>>? OrientationChanging;
 
     /// <inheritdoc/>
-    public event EventHandler<EventArgs<Orientation>> OrientationChanged;
+    public event EventHandler<EventArgs<Orientation>>? OrientationChanged;
 
     /// <summary>Called when <see cref="Orientation"/> has changed.</summary>
     /// <param name="newOrientation"></param>
@@ -132,9 +133,9 @@ public class Bar : View, IOrientation, IDesignable
     /// <summary>Removes a <see cref="Shortcut"/> at specified index of <see cref="View.Subviews"/>.</summary>
     /// <param name="index">The zero-based index of the item to remove.</param>
     /// <returns>The <see cref="Shortcut"/> removed.</returns>
-    public Shortcut RemoveShortcut (int index)
+    public Shortcut? RemoveShortcut (int index)
     {
-        View toRemove = null;
+        View? toRemove = null;
 
         for (var i = 0; i < Subviews.Count; i++)
         {
@@ -158,7 +159,7 @@ public class Bar : View, IOrientation, IDesignable
     {
         base.OnLayoutStarted (args);
 
-        View prevBarItem = null;
+        View? prevBarItem = null;
 
         switch (Orientation)
         {

+ 1 - 1
Terminal.Gui/Views/ColorPicker.cs

@@ -316,7 +316,7 @@ public class ColorPicker : View
 
     private void UpdateValueFromTextField (object? sender, HasFocusEventArgs e)
     {
-        if (e.NewValue)
+            if (e.NewValue)
         {
             return;
         }

+ 1 - 0
Terminal.Gui/Views/ColorPicker16.cs

@@ -51,6 +51,7 @@ public class ColorPicker16 : View
     }
 
     /// <summary>Fired when a color is picked.</summary>
+    [CanBeNull]
     public event EventHandler<ColorEventArgs> ColorChanged;
 
     /// <summary>Cursor for the selected color.</summary>

+ 3 - 0
Terminal.Gui/Views/TextField.cs

@@ -39,6 +39,9 @@ public class TextField : View
         Used = true;
         WantMousePositionReports = true;
 
+        // By default, disable hotkeys (in case someome sets Title)
+        HotKeySpecifier = new ('\xffff');
+
         _historyText.ChangeText += HistoryText_ChangeText;
 
         Initialized += TextField_Initialized;

+ 3 - 0
Terminal.Gui/Views/TextView.cs

@@ -1997,6 +1997,9 @@ public class TextView : View
         CursorVisibility = CursorVisibility.Default;
         Used = true;
 
+        // By default, disable hotkeys (in case someome sets Title)
+        HotKeySpecifier = new ('\xffff');
+
         _model.LinesLoaded += Model_LinesLoaded!;
         _historyText.ChangeText += HistoryText_ChangeText!;
 

+ 2 - 1
UICatalog/Scenarios/AdornmentEditor.cs

@@ -91,7 +91,8 @@ public class AdornmentEditor : View
         BorderStyle = LineStyle.Dashed;
         Initialized += AdornmentEditor_Initialized;
 
-        TabStop = TabBehavior.TabGroup;
+        CanFocus = true;
+        TabStop = TabBehavior.TabStop;
     }
 
     private void AdornmentEditor_Initialized (object sender, EventArgs e)

+ 3 - 26
UICatalog/Scenarios/Adornments.cs

@@ -130,36 +130,13 @@ public class Adornments : Scenario
 #endif
                               };
 
-        Application.MouseEvent += ApplicationOnMouseEvent;
+        editor.AutoSelectViewToEdit = true;
+        editor.AutoSelectSuperView = window;
+        editor.AutoSelectAdornments = true;
 
         Application.Run (app);
         app.Dispose ();
 
         Application.Shutdown ();
-
-        return;
-
-        void ApplicationOnMouseEvent (object sender, MouseEvent e)
-        {
-            if (!editor.AutoSelectViewToEdit || editor.FrameToScreen ().Contains (e.Position))
-            {
-                return;
-            }
-
-            // TODO: Add a setting (property) so only subviews of a specified view are considered.
-            View view = e.View;
-
-            if (view is { } && e.Flags == MouseFlags.Button1Clicked)
-            {
-                if (view is Adornment adornment)
-                {
-                    editor.ViewToEdit = adornment.Parent;
-                }
-                else
-                {
-                    editor.ViewToEdit = view;
-                }
-            }
-        }
     }
 }

+ 87 - 16
UICatalog/Scenarios/AdornmentsEditor.cs

@@ -1,4 +1,5 @@
-using System;
+#nullable enable
+using System;
 using System.Text;
 using Terminal.Gui;
 
@@ -19,31 +20,43 @@ public class AdornmentsEditor : View
 
         //SuperViewRendersLineCanvas = true;
 
+        CanFocus = true;
+
         TabStop = TabBehavior.TabGroup;
 
         Initialized += AdornmentsEditor_Initialized;
     }
 
     private readonly ViewDiagnosticFlags _savedDiagnosticFlags = Diagnostics;
-    private View _viewToEdit;
+    private View? _viewToEdit;
 
-    private Label _lblView; // Text describing the vi
+    private Label? _lblView; // Text describing the vi
 
-    private MarginEditor _marginEditor;
-    private BorderEditor _borderEditor;
-    private PaddingEditor _paddingEditor;
+    private MarginEditor? _marginEditor;
+    private BorderEditor? _borderEditor;
+    private PaddingEditor? _paddingEditor;
 
     // TODO: Move Diagnostics to a separate Editor class (DiagnosticsEditor?).
-    private CheckBox _diagPaddingCheckBox;
-    private CheckBox _diagRulerCheckBox;
+    private CheckBox? _diagPaddingCheckBox;
+    private CheckBox? _diagRulerCheckBox;
 
     /// <summary>
-    ///     Gets or sets whether the AdornmentsEditor should automatically select the View to edit when the mouse is clicked
-    ///     anywhere outside the editor.
+    ///     Gets or sets whether the AdornmentsEditor should automatically select the View to edit
+    ///     based on the values of <see cref="AutoSelectSuperView"/> and <see cref="AutoSelectAdornments"/>.
     /// </summary>
     public bool AutoSelectViewToEdit { get; set; }
 
-    public View ViewToEdit
+    /// <summary>
+    ///     Gets or sets the View that will scope the behavior of <see cref="AutoSelectViewToEdit"/>.
+    /// </summary>
+    public View? AutoSelectSuperView { get; set; }
+
+    /// <summary>
+    ///     Gets or sets whether auto select with the mouse will select Adornments or just Views.
+    /// </summary>
+    public bool AutoSelectAdornments { get; set; }
+
+    public View? ViewToEdit
     {
         get => _viewToEdit;
         set
@@ -55,11 +68,66 @@ public class AdornmentsEditor : View
 
             _viewToEdit = value;
 
-            _marginEditor.AdornmentToEdit = _viewToEdit?.Margin ?? null;
-            _borderEditor.AdornmentToEdit = _viewToEdit?.Border ?? null;
-            _paddingEditor.AdornmentToEdit = _viewToEdit?.Padding ?? null;
+            if (_viewToEdit is not Adornment)
+            {
+                _marginEditor!.AdornmentToEdit = _viewToEdit?.Margin ?? null;
+                _borderEditor!.AdornmentToEdit = _viewToEdit?.Border ?? null;
+                _paddingEditor!.AdornmentToEdit = _viewToEdit?.Padding ?? null;
+            }
 
-            _lblView.Text = $"{_viewToEdit?.GetType ().Name}: {_viewToEdit?.Id}" ?? string.Empty;
+            if (_lblView is { })
+            {
+                _lblView.Text = $"{_viewToEdit?.GetType ().Name}: {_viewToEdit?.Id}" ?? string.Empty;
+            }
+        }
+    }
+
+
+    private void NavigationOnFocusedChanged (object? sender, EventArgs e)
+    {
+        if (AutoSelectSuperView is null)
+        {
+            return;
+        }
+
+        if (ApplicationNavigation.IsInHierarchy (this, Application.Navigation!.GetFocused ()))
+        {
+            return;
+        }
+
+        if (!ApplicationNavigation.IsInHierarchy (AutoSelectSuperView, Application.Navigation!.GetFocused ()))
+        {
+            return;
+        }
+
+        ViewToEdit = Application.Navigation!.GetFocused ();
+    }
+
+    private void ApplicationOnMouseEvent (object? sender, MouseEvent e)
+    {
+        if (e.Flags != MouseFlags.Button1Clicked || !AutoSelectViewToEdit)
+        {
+            return;
+        }
+
+        if ((AutoSelectSuperView is { } && !AutoSelectSuperView.FrameToScreen ().Contains (e.Position))
+            || FrameToScreen ().Contains (e.Position))
+        {
+            return;
+        }
+
+        View view = e.View;
+
+        if (view is { })
+        {
+            if (view is Adornment adornment)
+            {
+                ViewToEdit = AutoSelectAdornments ? adornment : adornment.Parent;
+            }
+            else
+            {
+                ViewToEdit = view;
+            }
         }
     }
 
@@ -70,7 +138,7 @@ public class AdornmentsEditor : View
         base.Dispose (disposing);
     }
 
-    private void AdornmentsEditor_Initialized (object sender, EventArgs e)
+    private void AdornmentsEditor_Initialized (object? sender, EventArgs e)
     {
         BorderStyle = LineStyle.Dotted;
 
@@ -152,5 +220,8 @@ public class AdornmentsEditor : View
 
         Add (_diagRulerCheckBox);
         _diagRulerCheckBox.Y = Pos.Bottom (_diagPaddingCheckBox);
+
+        Application.MouseEvent += ApplicationOnMouseEvent;
+        Application.Navigation!.FocusedChanged += NavigationOnFocusedChanged;
     }
 }

+ 22 - 15
UICatalog/Scenarios/AllViewsTester.cs

@@ -68,7 +68,7 @@ public class AllViewsTester : Scenario
             Y = 0,
             Width = Dim.Auto (DimAutoStyle.Content),
             Height = Dim.Fill (),
-            CanFocus = false,
+            CanFocus = true,
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             Title = "Classes"
         };
@@ -84,7 +84,6 @@ public class AllViewsTester : Scenario
             SelectedItem = 0,
             Source = new ListWrapper<string> (new (_viewClasses.Keys.ToList ()))
         };
-        _classListView.OpenSelectedItem += (s, a) => { _settingsPane.SetFocus (); };
 
         _classListView.SelectedItemChanged += (s, args) =>
                                               {
@@ -95,10 +94,19 @@ public class AllViewsTester : Scenario
                                                       _hostPane.Remove (_curView);
                                                       _curView.Dispose ();
                                                       _curView = null;
-                                                      _hostPane.Clear ();
                                                   }
 
                                                   _curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);
+                                                  // Add
+                                                  _hostPane.Add (_curView);
+
+                                                  // Force ViewToEdit to be the view and not a subview
+                                                  if (_adornmentsEditor is { })
+                                                  {
+                                                      _adornmentsEditor.AutoSelectSuperView = _curView;
+
+                                                      _adornmentsEditor.ViewToEdit = _curView;
+                                                  }
                                               };
         _leftPane.Add (_classListView);
 
@@ -109,7 +117,9 @@ public class AllViewsTester : Scenario
             Width = Dim.Auto (),
             Height = Dim.Fill (),
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
-            BorderStyle = LineStyle.Single
+            BorderStyle = LineStyle.Single,
+            AutoSelectViewToEdit = true,
+            AutoSelectAdornments = false,
         };
 
         var expandButton = new ExpanderButton
@@ -125,7 +135,7 @@ public class AllViewsTester : Scenario
             Y = 0, // for menu
             Width = Dim.Fill (),
             Height = Dim.Auto (),
-            CanFocus = false,
+            CanFocus = true,
             ColorScheme = Colors.ColorSchemes ["TopLevel"],
             Title = "Settings"
         };
@@ -138,7 +148,8 @@ public class AllViewsTester : Scenario
             Y = 0,
             Height = Dim.Auto (),
             Width = Dim.Auto (),
-            Title = "Location (Pos)"
+            Title = "Location (Pos)",
+            TabStop = TabBehavior.TabStop,
         };
         _settingsPane.Add (_locationFrame);
 
@@ -188,7 +199,8 @@ public class AllViewsTester : Scenario
             Y = Pos.Y (_locationFrame),
             Height = Dim.Auto (),
             Width = Dim.Auto (),
-            Title = "Size (Dim)"
+            Title = "Size (Dim)",
+            TabStop = TabBehavior.TabStop,
         };
 
         radioItems = new [] { "Auto", "_Percent(width)", "_Fill(width)", "A_bsolute(width)" };
@@ -308,12 +320,15 @@ public class AllViewsTester : Scenario
             Y = Pos.Bottom (_settingsPane),
             Width = Dim.Fill (),
             Height = Dim.Fill (), // + 1 for status bar
+            CanFocus = true,
+            TabStop = TabBehavior.TabGroup,
             ColorScheme = Colors.ColorSchemes ["Dialog"]
         };
 
         app.Add (_leftPane, _adornmentsEditor, _settingsPane, _hostPane);
 
         _classListView.SelectedItem = 0;
+        _leftPane.SetFocus ();
 
         Application.Run (app);
         app.Dispose ();
@@ -370,10 +385,6 @@ public class AllViewsTester : Scenario
 
         view.Initialized += View_Initialized;
 
-        // Add
-        _hostPane.Add (view);
-        _hostPane.SetNeedsDisplay ();
-
         return view;
     }
 
@@ -476,12 +487,8 @@ public class AllViewsTester : Scenario
         UpdateTitle (_curView);
     }
 
-    private void Quit () { Application.RequestStop (); }
-
     private void UpdateSettings (View view)
     {
-        _adornmentsEditor.ViewToEdit = view;
-
         var x = view.X.ToString ();
         var y = view.Y.ToString ();
 

+ 3 - 26
UICatalog/Scenarios/ContentScrolling.cs

@@ -407,35 +407,12 @@ public class ContentScrolling : Scenario
 
         app.Closed += (s, e) => View.Diagnostics = _diagnosticFlags;
 
-        Application.MouseEvent += ApplicationOnMouseEvent;
+        editor.AutoSelectViewToEdit = true;
+        editor.AutoSelectSuperView = view;
+        editor.AutoSelectAdornments = false;
 
         Application.Run (app);
         app.Dispose ();
         Application.Shutdown ();
-
-        return;
-
-        void ApplicationOnMouseEvent (object sender, MouseEvent e)
-        {
-            if (!editor.AutoSelectViewToEdit || editor.FrameToScreen ().Contains (e.Position))
-            {
-                return;
-            }
-
-            // TODO: Add a setting (property) so only subviews of a specified view are considered.
-            View view = e.View;
-
-            if (view is { } && e.Flags == MouseFlags.Button1Clicked)
-            {
-                if (view is Adornment adornment)
-                {
-                    editor.ViewToEdit = adornment.Parent;
-                }
-                else
-                {
-                    editor.ViewToEdit = view;
-                }
-            }
-        }
     }
 }

+ 34 - 37
UICatalog/Scenarios/Navigation.cs

@@ -7,6 +7,8 @@ namespace UICatalog.Scenarios;
 [ScenarioCategory ("Layout")]
 public class Navigation : Scenario
 {
+    private int _hotkeyCount;
+
     public override void Main ()
     {
         Application.Init ();
@@ -31,7 +33,7 @@ public class Navigation : Scenario
             Title = "_1 Test Frame",
             X = Pos.Right (editor),
             Width = Dim.Fill (),
-            Height = Dim.Fill (),
+            Height = Dim.Fill ()
         };
 
         app.Add (testFrame);
@@ -40,27 +42,27 @@ public class Navigation : Scenario
         {
             X = 0,
             Y = 0,
-            Title = $"TopButton _{GetNextHotKey ()}",
+            Title = $"TopButton _{GetNextHotKey ()}"
         };
 
         testFrame.Add (button);
 
-        var tiledView1 = CreateTiledView (0, 2, 2);
-        var tiledView2 = CreateTiledView (1, Pos.Right (tiledView1), Pos.Top (tiledView1));
+        View tiledView1 = CreateTiledView (0, 2, 2);
+        View tiledView2 = CreateTiledView (1, Pos.Right (tiledView1), Pos.Top (tiledView1));
 
         testFrame.Add (tiledView1);
         testFrame.Add (tiledView2);
 
-        var tiledView3 = CreateTiledView (1, Pos.Right (tiledView2), Pos.Top (tiledView2));
+        View tiledView3 = CreateTiledView (1, Pos.Right (tiledView2), Pos.Top (tiledView2));
         tiledView3.TabStop = TabBehavior.TabGroup;
         tiledView3.BorderStyle = LineStyle.Double;
         testFrame.Add (tiledView3);
 
-        var overlappedView1 = CreateOverlappedView (2, Pos.Center () - 5, Pos.Center ());
-        var tiledSubView = CreateTiledView (4, 0, 2);
+        View overlappedView1 = CreateOverlappedView (2, Pos.Center () - 5, Pos.Center ());
+        View tiledSubView = CreateTiledView (4, 0, 2);
         overlappedView1.Add (tiledSubView);
 
-        var overlappedView2 = CreateOverlappedView (3, Pos.Center () + 10, Pos.Center () + 5);
+        View overlappedView2 = CreateOverlappedView (3, Pos.Center () + 10, Pos.Center () + 5);
 
         // BUGBUG: F6 through nested tab groups doesn't work yet.
 #if NESTED_TABGROUPS
@@ -79,87 +81,82 @@ public class Navigation : Scenario
         {
             X = Pos.AnchorEnd (),
             Y = Pos.AnchorEnd (),
-            Title = $"TopButton _{GetNextHotKey ()}",
+            Title = $"TopButton _{GetNextHotKey ()}"
         };
 
         testFrame.Add (button);
 
+        editor.AutoSelectSuperView = testFrame;
         Application.Run (app);
         app.Dispose ();
         Application.Shutdown ();
     }
 
-    private int _hotkeyCount;
-
-    private char GetNextHotKey ()
-    {
-        return (char)((int)'A' + _hotkeyCount++);
-    }
-
-    private View CreateTiledView (int id, Pos x, Pos y)
+    private View CreateOverlappedView (int id, Pos x, Pos y)
     {
-        View overlapped = new View
+        var overlapped = new View
         {
             X = x,
             Y = y,
             Height = Dim.Auto (),
             Width = Dim.Auto (),
-            Title = $"Tiled{id} _{GetNextHotKey ()}",
-            Id = $"Tiled{id}",
-            BorderStyle = LineStyle.Single,
+            Title = $"Overlapped{id} _{GetNextHotKey ()}",
+            ColorScheme = Colors.ColorSchemes ["Toplevel"],
+            Id = $"Overlapped{id}",
+            ShadowStyle = ShadowStyle.Transparent,
+            BorderStyle = LineStyle.Double,
             CanFocus = true, // Can't drag without this? BUGBUG
-            TabStop = TabBehavior.TabStop,
-            Arrangement = ViewArrangement.Fixed
+            TabStop = TabBehavior.TabGroup,
+            Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped
         };
 
         Button button = new ()
         {
-            Title = $"Tiled Button{id} _{GetNextHotKey ()}"
+            Title = $"Button{id} _{GetNextHotKey ()}"
         };
         overlapped.Add (button);
 
         button = new ()
         {
             Y = Pos.Bottom (button),
-            Title = $"Tiled Button{id} _{GetNextHotKey ()}"
+            Title = $"Button{id} _{GetNextHotKey ()}"
         };
         overlapped.Add (button);
 
         return overlapped;
     }
 
-
-    private View CreateOverlappedView (int id, Pos x, Pos y)
+    private View CreateTiledView (int id, Pos x, Pos y)
     {
-        View overlapped = new View
+        var overlapped = new View
         {
             X = x,
             Y = y,
             Height = Dim.Auto (),
             Width = Dim.Auto (),
-            Title = $"Overlapped{id} _{GetNextHotKey ()}",
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
-            Id = $"Overlapped{id}",
-            ShadowStyle = ShadowStyle.Transparent,
-            BorderStyle = LineStyle.Double,
+            Title = $"Tiled{id} _{GetNextHotKey ()}",
+            Id = $"Tiled{id}",
+            BorderStyle = LineStyle.Single,
             CanFocus = true, // Can't drag without this? BUGBUG
-            TabStop = TabBehavior.TabGroup,
-            Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped
+            TabStop = TabBehavior.TabStop,
+            Arrangement = ViewArrangement.Fixed
         };
 
         Button button = new ()
         {
-            Title = $"Button{id} _{GetNextHotKey ()}"
+            Title = $"Tiled Button{id} _{GetNextHotKey ()}"
         };
         overlapped.Add (button);
 
         button = new ()
         {
             Y = Pos.Bottom (button),
-            Title = $"Button{id} _{GetNextHotKey ()}"
+            Title = $"Tiled Button{id} _{GetNextHotKey ()}"
         };
         overlapped.Add (button);
 
         return overlapped;
     }
+
+    private char GetNextHotKey () { return (char)('A' + _hotkeyCount++); }
 }

+ 5 - 6
UICatalog/Scenarios/NumericUpDownDemo.cs

@@ -15,7 +15,6 @@ public class NumericUpDownDemo : Scenario
         Window app = new ()
         {
             Title = GetQuitKeyAndName (),
-            TabStop = TabBehavior.TabGroup
         };
 
         var editor = new AdornmentsEditor
@@ -23,7 +22,6 @@ public class NumericUpDownDemo : Scenario
             X = 0,
             Y = 0,
             AutoSelectViewToEdit = true,
-            TabStop = TabBehavior.NoStop
         };
         app.Add (editor);
 
@@ -50,15 +48,15 @@ public class NumericUpDownDemo : Scenario
         {
             floatEditor!.NumericUpDown!.Increment = 0.1F;
             floatEditor!.NumericUpDown!.Format = "{0:0.0}";
-
         }
 
+        editor.AutoSelectSuperView = app;
+        intEditor.SetFocus ();
+
         Application.Run (app);
         app.Dispose ();
         Application.Shutdown ();
-
     }
-
 }
 
 internal class NumericUpDownEditor<T> : View where T : notnull
@@ -95,6 +93,7 @@ internal class NumericUpDownEditor<T> : View where T : notnull
         Width = Dim.Auto (DimAutoStyle.Content);
         Height = Dim.Auto (DimAutoStyle.Content);
         TabStop = TabBehavior.TabGroup;
+        CanFocus = true;
 
         Initialized += NumericUpDownEditorInitialized;
 
@@ -184,7 +183,7 @@ internal class NumericUpDownEditor<T> : View where T : notnull
                     // Test format to ensure it's valid
                     _ = string.Format (_format.Text, _value);
                     _numericUpDown.Format = _format.Text;
-                    
+
                     _format.ColorScheme = SuperView.ColorScheme;
 
                 }

+ 1 - 1
UICatalog/Scenarios/ProgressBarStyles.cs

@@ -35,7 +35,7 @@ public class ProgressBarStyles : Scenario
 
         var editor = new AdornmentsEditor ()
         {
-            AutoSelectViewToEdit = false
+            AutoSelectViewToEdit = true
         };
         app.Add (editor);
 

+ 3 - 25
UICatalog/Scenarios/ShadowStyles.cs

@@ -55,36 +55,14 @@ public class ShadowStyles : Scenario
         };
         app.Add (button);
 
-        Application.MouseEvent += ApplicationOnMouseEvent;
+        editor.AutoSelectViewToEdit = true;
+        editor.AutoSelectSuperView = app;
+        editor.AutoSelectAdornments = false;
 
         Application.Run (app);
         app.Dispose ();
 
         Application.Shutdown ();
 
-        return;
-
-        void ApplicationOnMouseEvent (object sender, MouseEvent e)
-        {
-            if (!editor.AutoSelectViewToEdit || editor.FrameToScreen ().Contains (e.Position))
-            {
-                return;
-            }
-
-            // TODO: Add a setting (property) so only subviews of a specified view are considered.
-            View view = e.View;
-
-            if (view is { } && e.Flags == MouseFlags.Button1Clicked)
-            {
-                if (view is Adornment adornment)
-                {
-                    editor.ViewToEdit = adornment.Parent;
-                }
-                else
-                {
-                    editor.ViewToEdit = view;
-                }
-            }
-        }
     }
 }

+ 3 - 108
UICatalog/Scenarios/ViewExperiments.cs

@@ -24,7 +24,6 @@ public class ViewExperiments : Scenario
         {
             X = 0,
             Y = 0,
-            AutoSelectViewToEdit = true,
             TabStop = TabBehavior.NoStop
         };
         app.Add (editor);
@@ -56,9 +55,10 @@ public class ViewExperiments : Scenario
         };
 
         testFrame.Add (button);
-        Application.MouseEvent += ApplicationOnMouseEvent;
-        Application.Navigation.FocusedChanged += NavigationOnFocusedChanged;
 
+        editor.AutoSelectViewToEdit = true;
+        editor.AutoSelectSuperView = testFrame;
+        editor.AutoSelectAdornments = true;
 
         Application.Run (app);
         app.Dispose ();
@@ -66,44 +66,6 @@ public class ViewExperiments : Scenario
         Application.Shutdown ();
 
         return;
-
-
-        void NavigationOnFocusedChanged (object sender, EventArgs e)
-        {
-            if (!ApplicationNavigation.IsInHierarchy (testFrame, Application.Navigation!.GetFocused ()))
-            {
-                return;
-            }
-
-            editor.ViewToEdit = Application.Navigation!.GetFocused ();
-        }
-        void ApplicationOnMouseEvent (object sender, MouseEvent e)
-        {
-            if (e.Flags != MouseFlags.Button1Clicked)
-            {
-                return;
-            }
-
-            if (!editor.AutoSelectViewToEdit || !testFrame.FrameToScreen ().Contains (e.Position))
-            {
-                return;
-            }
-
-            // TODO: Add a setting (property) so only subviews of a specified view are considered.
-            View view = e.View;
-
-            if (view is { } && e.Flags == MouseFlags.Button1Clicked)
-            {
-                if (view is Adornment adornment)
-                {
-                    editor.ViewToEdit = adornment.Parent;
-                }
-                else
-                {
-                    editor.ViewToEdit = view;
-                }
-            }
-        }
     }
 
     private int _hotkeyCount;
@@ -112,71 +74,4 @@ public class ViewExperiments : Scenario
     {
         return (char)((int)'A' + _hotkeyCount++);
     }
-
-    private View CreateTiledView (int id, Pos x, Pos y)
-    {
-        View overlapped = new View
-        {
-            X = x,
-            Y = y,
-            Height = Dim.Auto (),
-            Width = Dim.Auto (),
-            Title = $"Tiled{id} _{GetNextHotKey ()}",
-            Id = $"Tiled{id}",
-            BorderStyle = LineStyle.Single,
-            CanFocus = true, // Can't drag without this? BUGBUG
-            TabStop = TabBehavior.TabGroup,
-            Arrangement = ViewArrangement.Fixed
-        };
-
-        Button button = new ()
-        {
-            Title = $"Tiled Button{id} _{GetNextHotKey ()}"
-        };
-        overlapped.Add (button);
-
-        button = new ()
-        {
-            Y = Pos.Bottom (button),
-            Title = $"Tiled Button{id} _{GetNextHotKey ()}"
-        };
-        overlapped.Add (button);
-
-        return overlapped;
-    }
-
-
-    private View CreateOverlappedView (int id, Pos x, Pos y)
-    {
-        View overlapped = new View
-        {
-            X = x,
-            Y = y,
-            Height = Dim.Auto (),
-            Width = Dim.Auto (),
-            Title = $"Overlapped{id} _{GetNextHotKey ()}",
-            ColorScheme = Colors.ColorSchemes ["Toplevel"],
-            Id = $"Overlapped{id}",
-            ShadowStyle = ShadowStyle.Transparent,
-            BorderStyle = LineStyle.Double,
-            CanFocus = true, // Can't drag without this? BUGBUG
-            TabStop = TabBehavior.TabGroup,
-            Arrangement = ViewArrangement.Movable | ViewArrangement.Overlapped
-        };
-
-        Button button = new ()
-        {
-            Title = $"Button{id} _{GetNextHotKey ()}"
-        };
-        overlapped.Add (button);
-
-        button = new ()
-        {
-            Y = Pos.Bottom (button),
-            Title = $"Button{id} _{GetNextHotKey ()}"
-        };
-        overlapped.Add (button);
-
-        return overlapped;
-    }
 }