diff --git a/Terminal.Gui/Application/Application.Keyboard.cs b/Terminal.Gui/Application/Application.Keyboard.cs
index 969d4c31e..147a07e3b 100644
--- a/Terminal.Gui/Application/Application.Keyboard.cs
+++ b/Terminal.Gui/Application/Application.Keyboard.cs
@@ -301,7 +301,6 @@ public static partial class Application // Keyboard handling
Command.NextView,
() =>
{
- // TODO: Move this method to Application.Navigation.cs
ApplicationNavigation.MoveNextView ();
return true;
@@ -312,7 +311,6 @@ public static partial class Application // Keyboard handling
Command.PreviousView,
() =>
{
- // TODO: Move this method to Application.Navigation.cs
ApplicationNavigation.MovePreviousView ();
return true;
@@ -323,7 +321,6 @@ public static partial class Application // Keyboard handling
Command.NextViewOrTop,
() =>
{
- // TODO: Move this method to Application.Navigation.cs
ApplicationNavigation.MoveNextViewOrTop ();
return true;
@@ -334,7 +331,6 @@ public static partial class Application // Keyboard handling
Command.PreviousViewOrTop,
() =>
{
- // TODO: Move this method to Application.Navigation.cs
ApplicationNavigation.MovePreviousViewOrTop ();
return true;
diff --git a/Terminal.Gui/Application/Application.Navigation.cs b/Terminal.Gui/Application/Application.Navigation.cs
index 6ebfeabc2..00ff880eb 100644
--- a/Terminal.Gui/Application/Application.Navigation.cs
+++ b/Terminal.Gui/Application/Application.Navigation.cs
@@ -67,9 +67,9 @@ internal static class ApplicationNavigation
{
Toplevel? top = Application.Current!.Modal ? Application.Current : Application.Top;
- if (!Application.Current.AdvanceFocus (NavigationDirection.Forward))
+ if (!Application.Current.AdvanceFocus (NavigationDirection.Forward, true))
{
- Application.Current.AdvanceFocus (NavigationDirection.Forward);
+ Application.Current.AdvanceFocus (NavigationDirection.Forward, true);
}
if (top != Application.Current.Focused && top != Application.Current.Focused?.Focused)
@@ -129,11 +129,11 @@ internal static class ApplicationNavigation
if (ApplicationOverlapped.OverlappedTop is null)
{
Toplevel? top = Application.Current!.Modal ? Application.Current : Application.Top;
- top!.AdvanceFocus (NavigationDirection.Backward);
+ top!.AdvanceFocus (NavigationDirection.Backward, true);
if (top.Focused is null)
{
- top.AdvanceFocus (NavigationDirection.Backward);
+ top.AdvanceFocus (NavigationDirection.Backward, true);
}
top.SetNeedsDisplay ();
diff --git a/Terminal.Gui/View/View.Navigation.cs b/Terminal.Gui/View/View.Navigation.cs
index 81fdd0cc8..b760e8fce 100644
--- a/Terminal.Gui/View/View.Navigation.cs
+++ b/Terminal.Gui/View/View.Navigation.cs
@@ -523,11 +523,12 @@ public partial class View // Focus and cross-view navigation management (TabStop
///
///
///
+ /// If will advance into ...
///
/// if focus was changed to another subview (or stayed on this one),
/// otherwise.
///
- public bool AdvanceFocus (NavigationDirection direction)
+ public bool AdvanceFocus (NavigationDirection direction, bool acrossGroupOrOverlapped = false)
{
if (!CanBeVisible (this))
{
@@ -569,14 +570,30 @@ public partial class View // Focus and cross-view navigation management (TabStop
if (w.HasFocus)
{
// A subview has focus, tell *it* to FocusNext
- if (w.AdvanceFocus (direction))
+ if (w.AdvanceFocus (direction, acrossGroupOrOverlapped))
{
// The subview changed which of it's subviews had focus
return true;
}
+ else
+ {
+ if (acrossGroupOrOverlapped && Arrangement.HasFlag (ViewArrangement.Overlapped))
+ {
+ return false;
+ }
+ }
Debug.Assert (w.HasFocus);
+ if (w.Focused is null)
+ {
+ // No next focusable view was found.
+ if (w.Arrangement.HasFlag (ViewArrangement.Overlapped))
+ {
+ // Keep focus w/in w
+ return false;
+ }
+ }
// The subview has no subviews that can be next. Cache that we found a focused subview.
focusedFound = true;
@@ -589,17 +606,17 @@ public partial class View // Focus and cross-view navigation management (TabStop
// Make Focused Leave
Focused.SetHasFocus (false, w);
- //// If the focused view is overlapped don't focus on the next if it's not overlapped.
- //if (Focused.Arrangement.HasFlag (ViewArrangement.Overlapped)/* && !w.Arrangement.HasFlag (ViewArrangement.Overlapped)*/)
+ // If the focused view is overlapped don't focus on the next if it's not overlapped.
+ //if (acrossGroupOrOverlapped && Focused.Arrangement.HasFlag (ViewArrangement.Overlapped)/* && !w.Arrangement.HasFlag (ViewArrangement.Overlapped)*/)
//{
// return false;
//}
- //// If the focused view is not overlapped and the next is, skip it
- //if (!Focused.Arrangement.HasFlag (ViewArrangement.Overlapped) && w.Arrangement.HasFlag (ViewArrangement.Overlapped))
- //{
- // continue;
- //}
+ // If the focused view is not overlapped and the next is, skip it
+ if (!acrossGroupOrOverlapped && !Focused.Arrangement.HasFlag (ViewArrangement.Overlapped) && w.Arrangement.HasFlag (ViewArrangement.Overlapped))
+ {
+ continue;
+ }
switch (direction)
{
@@ -766,7 +783,8 @@ public partial class View // Focus and cross-view navigation management (TabStop
{
return;
}
-
+
+ // BUGBUG: TabStop and CanFocus should be decoupled.
_tabStop = CanFocus && value;
}
}
diff --git a/Terminal.Gui/View/ViewArrangement.cs b/Terminal.Gui/View/ViewArrangement.cs
index 0143b082e..5b38fd658 100644
--- a/Terminal.Gui/View/ViewArrangement.cs
+++ b/Terminal.Gui/View/ViewArrangement.cs
@@ -67,5 +67,5 @@ public enum ViewArrangement
/// Use Ctrl-Tab (Ctrl-PageDown) / Ctrl-Shift-Tab (Ctrl-PageUp) to move between overlapped views.
///
///
- Overlapped = 32
+ Overlapped = 32,
}
diff --git a/UICatalog/Scenarios/AdornmentEditor.cs b/UICatalog/Scenarios/AdornmentEditor.cs
index e97d25ada..d9a9b1293 100644
--- a/UICatalog/Scenarios/AdornmentEditor.cs
+++ b/UICatalog/Scenarios/AdornmentEditor.cs
@@ -90,6 +90,9 @@ public class AdornmentEditor : View
BorderStyle = LineStyle.Dashed;
Initialized += AdornmentEditor_Initialized;
+
+ //Arrangement = ViewArrangement.Group;
+
}
private void AdornmentEditor_Initialized (object sender, EventArgs e)
diff --git a/UICatalog/Scenarios/ViewExperiments.cs b/UICatalog/Scenarios/ViewExperiments.cs
index 4c212b8b7..d9ba7db94 100644
--- a/UICatalog/Scenarios/ViewExperiments.cs
+++ b/UICatalog/Scenarios/ViewExperiments.cs
@@ -18,6 +18,7 @@ public class ViewExperiments : Scenario
Title = GetQuitKeyAndName ()
};
+
var view = new View
{
X = 2,
@@ -81,6 +82,22 @@ public class ViewExperiments : Scenario
view2.Add (button);
+ var editor = new AdornmentsEditor
+ {
+ X = 0,
+ Y = 0,
+ AutoSelectViewToEdit = true
+ };
+ app.Add (editor);
+
+ button = new ()
+ {
+ Y = 0,
+ X = Pos.X (view),
+ Title = "Button_0",
+ };
+ app.Add (button);
+
button = new ()
{
X = Pos.AnchorEnd (),
@@ -88,14 +105,6 @@ public class ViewExperiments : Scenario
Title = "Button_5",
};
- var editor = new AdornmentsEditor
- {
- X = 0,
- Y = 0,
- AutoSelectViewToEdit = true
- };
-
- app.Add (editor);
view.X = 34;
view.Y = 4;
app.Add (view);