Skip to content

Commit

Permalink
Remove GetNextFocusableElement
Browse files Browse the repository at this point in the history
  • Loading branch information
enisn committed Apr 3, 2024
1 parent 2a604c7 commit 9b8bd59
Showing 1 changed file with 0 additions and 63 deletions.
63 changes: 0 additions & 63 deletions src/UraniumUI/Extensions/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,67 +112,4 @@ public static bool IsRtl(this VisualElement element)
// Fallback to culture:
return CultureInfo.CurrentCulture.TextInfo.IsRightToLeft;
}

public static IVisualTreeElement GetNextFocusableElement(IVisualTreeElement parent, IVisualTreeElement startAfterElement)
{
if (parent == null || startAfterElement == null)
{
//Nothing more to search
return null;
}

var parentControls = parent.GetVisualChildren();

if (parentControls != null)
{
IVisualTreeElement firstFocusableElementBefore = null;
IVisualTreeElement firstFocusableElementAfter = null;

bool startElementFound = false;

foreach (var control in parentControls)
{
if (control.Equals(startAfterElement))
{
startElementFound = true;

continue;
}

if (control is View view && view.IsEnabled && view.IsVisible)
{
if (startElementFound)
{
firstFocusableElementAfter ??= control;
}
else
{
firstFocusableElementBefore ??= control;
}
}

//We have valid candidates, break out
if (firstFocusableElementBefore != null && firstFocusableElementAfter != null)
{
break;
}
}

if (firstFocusableElementAfter != null)
{
return firstFocusableElementAfter;
}
else if (firstFocusableElementBefore != null)
{
return firstFocusableElementBefore;
}
else
{
//Go up the stack
return GetNextFocusableElement(parent.GetVisualParent(), parent);
}
}

return null;
}
}

0 comments on commit 9b8bd59

Please sign in to comment.