From f1c87b4043db8996a866c89876a58e9c98a434c4 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 29 Jul 2021 10:43:41 +0200 Subject: [PATCH] Added KeyboardNavigationMode.Local. --- src/Avalonia.Input/KeyboardNavigationMode.cs | 7 ++++++- src/Avalonia.Input/Navigation/TabNavigation.cs | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Input/KeyboardNavigationMode.cs b/src/Avalonia.Input/KeyboardNavigationMode.cs index 41e778bf49..e01ebf0330 100644 --- a/src/Avalonia.Input/KeyboardNavigationMode.cs +++ b/src/Avalonia.Input/KeyboardNavigationMode.cs @@ -36,5 +36,10 @@ namespace Avalonia.Input /// The container's children will not be focused when using the tab key. /// None, + + /// + /// TabIndexes are considered on local subtree only inside this container + /// + Local, } -} \ No newline at end of file +} diff --git a/src/Avalonia.Input/Navigation/TabNavigation.cs b/src/Avalonia.Input/Navigation/TabNavigation.cs index 12842e4f40..ed7df67bf2 100644 --- a/src/Avalonia.Input/Navigation/TabNavigation.cs +++ b/src/Avalonia.Input/Navigation/TabNavigation.cs @@ -152,6 +152,9 @@ namespace Avalonia.Input.Navigation // Look for element with the same TabIndex before the current element while ((nextTabElement = GetPrevTabInGroup(nextTabElement, container, tabbingType)) != null) { + if (nextTabElement == container && tabbingType == KeyboardNavigationMode.Local) + break; + // At this point nextTabElement is TabStop or TabGroup // In case it is a TabStop only return the element if (IsTabStop(nextTabElement) && !IsGroup(nextTabElement))