Browse Source

Refactored subview methods. Fixed issues.

Tig 11 months ago
parent
commit
1a16f43495

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

@@ -495,7 +495,7 @@ public class ComboBox : View, IDesignable
         Reset (true);
         _listview.Clear ();
         _listview.TabStop = TabBehavior.NoStop;
-        SuperView?.MoveSubviewToEnd (this);
+        SuperView?.MoveSubviewToStart (this);
         Rectangle rect = _listview.ViewportToScreen (_listview.IsInitialized ? _listview.Viewport : Rectangle.Empty);
         SuperView?.SetNeedsDisplay (rect);
         OnCollapsed ();

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

@@ -543,7 +543,7 @@ public class FileDialog : Dialog
         {
             _btnCancel.X = Pos.Func (CalculateOkButtonPosX);
             _btnOk.X = Pos.Right (_btnCancel) + 1;
-            MoveSubviewTowardsFront (_btnCancel);
+            MoveSubviewTowardsStart (_btnCancel);
         }
         LayoutSubviews ();
     }

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

@@ -1348,7 +1348,7 @@ public class TabView : View
                 _leftScrollIndicator.Visible = true;
 
                 // Ensures this is clicked instead of the first tab
-                MoveSubviewToStart (_leftScrollIndicator);
+                MoveSubviewToEnd (_leftScrollIndicator);
                 _leftScrollIndicator.Draw ();
             }
             else

+ 3 - 3
UnitTests/View/SubviewTests.cs

@@ -426,14 +426,14 @@ public class SubviewTests
 
         superView.Add (subview1, subview2, subview3);
 
-        superView.MoveSubviewTowardsFront (subview2);
+        superView.MoveSubviewTowardsStart (subview2);
         Assert.Equal (subview2, superView.Subviews [0]);
 
-        superView.MoveSubviewTowardsFront (subview3);
+        superView.MoveSubviewTowardsStart (subview3);
         Assert.Equal (subview3, superView.Subviews [1]);
 
         // Already at front, what happens?
-        superView.MoveSubviewTowardsFront (subview2);
+        superView.MoveSubviewTowardsStart (subview2);
         Assert.Equal (subview2, superView.Subviews [0]);
     }
 

+ 1 - 1
docfx/docs/migratingfromv1.md

@@ -250,7 +250,7 @@ See also [Keyboard](keyboard.md) where HotKey is covered more deeply...
   - `public bool FocusDeepest (NavigationDirection direction, TabBehavior? behavior)` 
 * In v1, the `View.OnEnter/Enter` and `View.OnLeave/Leave` virtual methods/events could be used to notify that a view had gained or lost focus, but had confusing semantics around what it mean to override (requiring calling `base`) and bug-ridden behavior on what the return values signified. The "Enter" and "Leave" terminology was confusing. In v2, `View.OnHasFocusChanging/HasFocusChanging` and `View.OnHasFocusChanged/HasFocusChanged` replace `View.OnEnter/Enter` and `View.OnLeave/Leave`. These virtual methods/events follow standard Terminal.Gui event patterns. The `View.OnHasFocusChanging/HasFocusChanging` event supports being cancelled.
 * In v1, the concept of `Mdi` views included a large amount of complex code (in `Toplevel` and `Application`) for dealing with navigation across overlapped Views. This has all been radically simplified in v2. Any View can work in an "overlapped" or "tiled" way. See [navigation.md](navigation.md) for more details.
-* The `View.TabIndex` and `View.TabIndexes` have been removed. Change the order of the views in `View.Subviews` to change the navigation order. 
+* The `View.TabIndex` and `View.TabIndexes` have been removed. Change the order of the views in `View.Subviews` to change the navigation order (using, for example `View.MoveSubviewTowardsStart()`).
 
 ### How to Fix (Focus API)