Refactored subview methods. Fixed issues.

This commit is contained in:
Tig
2024-08-26 14:10:02 -07:00
parent 4b479a60f3
commit 1a16f43495
5 changed files with 7 additions and 7 deletions

View File

@@ -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 ();

View File

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

View File

@@ -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

View File

@@ -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]);
}

View File

@@ -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)