AdvanceFocus works correctly for most cases

This commit is contained in:
Tig
2024-08-26 07:04:11 -07:00
parent 6667b33cf5
commit 7f3b0eb55b
2 changed files with 18 additions and 19 deletions

View File

@@ -429,28 +429,27 @@ public partial class View // Focus and cross-view navigation management (TabStop
// We're moving beyond the last subview
// Determine if focus should remain in this focus chain, or move to the superview's focus chain
if (SuperView is { } && SuperView.TabStop != TabBehavior.NoStop && SuperView.GetScopedTabIndexes (direction, behavior).Length > 1)
// - If we are TabStop and our SuperView is TabStop move to superview's focus chain
if (TabStop == TabBehavior.TabStop && SuperView is { TabStop: TabBehavior.TabStop })
{
//if (behavior == TabBehavior.TabGroup && behavior == TabStop && SuperView?.TabStop == TabBehavior.TabGroup)
{
// Our superview has an focusable subview in addition to us
return false;
}
return false;
}
// If our superview
//if (behavior == TabBehavior.TabGroup && behavior == TabStop && SuperView?.TabStop == TabBehavior.TabGroup)
// - If we are TabStop and our SuperView has at least one other TabStop subview, move to the SuperView's chain
if (TabStop == TabBehavior.TabStop && SuperView is { } && SuperView.GetScopedTabIndexes (direction, behavior).Length > 1)
{
next = 0;
//return
return false;
}
//// Go down the subview-hierarchy and leave
//// BUGBUG: This doesn't seem right
//Focused.HasFocus = false;
//// TODO: Should we check the return value of SetHasFocus?
//return false;
// - If we are TabGrup and our SuperView has at least one other TabGroup subview, move to the SuperView's chain
if (TabStop == TabBehavior.TabGroup && SuperView is { TabStop: TabBehavior.TabGroup })
{
if (behavior == TabBehavior.TabGroup)
{
// Wrap to first focusable views
// BUGBUG: This should do a Restore Focus instead
index = GetScopedTabIndexes (direction, null);
}
}
}

View File

@@ -53,11 +53,11 @@ public class ViewExperiments : Scenario
testFrame.Add (tiledView1);
testFrame.Add (tiledView2);
var overlappedView1 = CreateOverlappedView (2, Pos.Center(), Pos.Center());
var overlappedView1 = CreateOverlappedView (2, Pos.Center()-5, Pos.Center());
var tiledSubView = CreateTiledView (4, 0, 2);
overlappedView1.Add (tiledSubView);
var overlappedView2 = CreateOverlappedView (3, Pos.Center() + 5, Pos.Center() + 5);
var overlappedView2 = CreateOverlappedView (3, Pos.Center() + 10, Pos.Center() + 5);
tiledSubView = CreateTiledView (4, 0, 2);
overlappedView2.Add (tiledSubView);