|
|
|
@ -44,7 +44,7 @@ namespace Avalonia.Input.Navigation |
|
|
|
GetFirstInNextContainer(element, direction); |
|
|
|
case KeyboardNavigationMode.Cycle: |
|
|
|
return GetNextInContainer(element, container, direction) ?? |
|
|
|
GetFocusableDescendent(container, direction); |
|
|
|
GetFocusableDescendant(container, direction); |
|
|
|
case KeyboardNavigationMode.Contained: |
|
|
|
return GetNextInContainer(element, container, direction); |
|
|
|
default: |
|
|
|
@ -53,29 +53,29 @@ namespace Avalonia.Input.Navigation |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return GetFocusableDescendents(element).FirstOrDefault(); |
|
|
|
return GetFocusableDescendants(element).FirstOrDefault(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the first or last focusable descendent of the specified element.
|
|
|
|
/// Gets the first or last focusable descendant of the specified element.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="container">The element.</param>
|
|
|
|
/// <param name="direction">The direction to search.</param>
|
|
|
|
/// <returns>The element or null if not found.##</returns>
|
|
|
|
private static IInputElement GetFocusableDescendent(IInputElement container, NavigationDirection direction) |
|
|
|
private static IInputElement GetFocusableDescendant(IInputElement container, NavigationDirection direction) |
|
|
|
{ |
|
|
|
return direction == NavigationDirection.Next ? |
|
|
|
GetFocusableDescendents(container).FirstOrDefault() : |
|
|
|
GetFocusableDescendents(container).LastOrDefault(); |
|
|
|
GetFocusableDescendants(container).FirstOrDefault() : |
|
|
|
GetFocusableDescendants(container).LastOrDefault(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the focusable descendents of the specified element.
|
|
|
|
/// Gets the focusable descendants of the specified element.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="element">The element.</param>
|
|
|
|
/// <returns>The element's focusable descendents.</returns>
|
|
|
|
private static IEnumerable<IInputElement> GetFocusableDescendents(IInputElement element) |
|
|
|
/// <returns>The element's focusable descendants.</returns>
|
|
|
|
private static IEnumerable<IInputElement> GetFocusableDescendants(IInputElement element) |
|
|
|
{ |
|
|
|
var mode = KeyboardNavigation.GetTabNavigation((InputElement)element); |
|
|
|
|
|
|
|
@ -108,11 +108,11 @@ namespace Avalonia.Input.Navigation |
|
|
|
yield return child; |
|
|
|
} |
|
|
|
|
|
|
|
if (child.CanFocusDescendents()) |
|
|
|
if (child.CanFocusDescendants()) |
|
|
|
{ |
|
|
|
foreach (var descendent in GetFocusableDescendents(child)) |
|
|
|
foreach (var descendant in GetFocusableDescendants(child)) |
|
|
|
{ |
|
|
|
yield return descendent; |
|
|
|
yield return descendant; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -132,11 +132,11 @@ namespace Avalonia.Input.Navigation |
|
|
|
{ |
|
|
|
if (direction == NavigationDirection.Next) |
|
|
|
{ |
|
|
|
var descendent = GetFocusableDescendents(element).FirstOrDefault(); |
|
|
|
var descendant = GetFocusableDescendants(element).FirstOrDefault(); |
|
|
|
|
|
|
|
if (descendent != null) |
|
|
|
if (descendant != null) |
|
|
|
{ |
|
|
|
return descendent; |
|
|
|
return descendant; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -167,11 +167,11 @@ namespace Avalonia.Input.Navigation |
|
|
|
|
|
|
|
if (element != null && direction == NavigationDirection.Previous) |
|
|
|
{ |
|
|
|
var descendent = GetFocusableDescendents(element).LastOrDefault(); |
|
|
|
var descendant = GetFocusableDescendants(element).LastOrDefault(); |
|
|
|
|
|
|
|
if (descendent != null) |
|
|
|
if (descendant != null) |
|
|
|
{ |
|
|
|
return descendent; |
|
|
|
return descendant; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -203,7 +203,7 @@ namespace Avalonia.Input.Navigation |
|
|
|
|
|
|
|
var siblings = parent.GetVisualChildren() |
|
|
|
.OfType<IInputElement>() |
|
|
|
.Where(FocusExtensions.CanFocusDescendents); |
|
|
|
.Where(FocusExtensions.CanFocusDescendants); |
|
|
|
var sibling = direction == NavigationDirection.Next ? |
|
|
|
siblings.SkipWhile(x => x != container).Skip(1).FirstOrDefault() : |
|
|
|
siblings.TakeWhile(x => x != container).LastOrDefault(); |
|
|
|
@ -217,8 +217,8 @@ namespace Avalonia.Input.Navigation |
|
|
|
else |
|
|
|
{ |
|
|
|
next = direction == NavigationDirection.Next ? |
|
|
|
GetFocusableDescendents(sibling).FirstOrDefault() : |
|
|
|
GetFocusableDescendents(sibling).LastOrDefault(); |
|
|
|
GetFocusableDescendants(sibling).FirstOrDefault() : |
|
|
|
GetFocusableDescendants(sibling).LastOrDefault(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -230,8 +230,8 @@ namespace Avalonia.Input.Navigation |
|
|
|
else |
|
|
|
{ |
|
|
|
next = direction == NavigationDirection.Next ? |
|
|
|
GetFocusableDescendents(container).FirstOrDefault() : |
|
|
|
GetFocusableDescendents(container).LastOrDefault(); |
|
|
|
GetFocusableDescendants(container).FirstOrDefault() : |
|
|
|
GetFocusableDescendants(container).LastOrDefault(); |
|
|
|
} |
|
|
|
|
|
|
|
return next; |
|
|
|
|