From 3870c4792fd7751bc4bc92187a2649a67cd3bfc4 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 4 Aug 2015 20:59:22 +0200 Subject: [PATCH] Refactored tab navigation. In preparation for directional navigation. --- Perspex.Controls/Perspex.Controls.csproj | 1 - Perspex.Controls/StackPanel.cs | 8 +- .../INavigableContainer.cs | 14 +- Perspex.Input/KeyboardNavigation.cs | 41 +++- Perspex.Input/KeyboardNavigationHandler.cs | 192 +++++++----------- Perspex.Input/Perspex.Input.csproj | 1 + .../KeyboardNavigationTests_Tab.cs | 104 +++++----- 7 files changed, 179 insertions(+), 182 deletions(-) rename Perspex.Controls/INavigablePanel.cs => Perspex.Input/INavigableContainer.cs (58%) diff --git a/Perspex.Controls/Perspex.Controls.csproj b/Perspex.Controls/Perspex.Controls.csproj index 35400cf22e..f65691050e 100644 --- a/Perspex.Controls/Perspex.Controls.csproj +++ b/Perspex.Controls/Perspex.Controls.csproj @@ -55,7 +55,6 @@ - diff --git a/Perspex.Controls/StackPanel.cs b/Perspex.Controls/StackPanel.cs index 4e3bc8b000..9e461b33f5 100644 --- a/Perspex.Controls/StackPanel.cs +++ b/Perspex.Controls/StackPanel.cs @@ -28,7 +28,7 @@ namespace Perspex.Controls /// /// A panel which lays out its children horizontally or vertically. /// - public class StackPanel : Panel, INavigablePanel + public class StackPanel : Panel, INavigableContainer { /// /// Defines the property. @@ -75,10 +75,10 @@ namespace Perspex.Controls /// The movement direction. /// The control from which movement begins. /// The control. - IControl INavigablePanel.GetControl(FocusNavigationDirection direction, IControl from) + IInputElement INavigableContainer.GetControl(FocusNavigationDirection direction, IInputElement from) { var horiz = this.Orientation == Orientation.Horizontal; - int index = this.Children.IndexOf(from); + int index = this.Children.IndexOf((IControl)from); switch (direction) { @@ -92,7 +92,7 @@ namespace Perspex.Controls ++index; break; case FocusNavigationDirection.Previous: - ++index; + --index; break; case FocusNavigationDirection.Left: index = horiz ? index - 1 : -1; diff --git a/Perspex.Controls/INavigablePanel.cs b/Perspex.Input/INavigableContainer.cs similarity index 58% rename from Perspex.Controls/INavigablePanel.cs rename to Perspex.Input/INavigableContainer.cs index 23730e2e1c..a03e037022 100644 --- a/Perspex.Controls/INavigablePanel.cs +++ b/Perspex.Input/INavigableContainer.cs @@ -1,17 +1,15 @@ // ----------------------------------------------------------------------- -// -// Copyright 2014 MIT Licence. See licence.md for more information. +// +// Copyright 2015 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- -namespace Perspex.Controls +namespace Perspex.Input { - using Perspex.Input; - /// - /// Defines a panel in which the child controls can be navigated by keyboard. + /// Defines a container in which the child controls can be navigated by keyboard. /// - public interface INavigablePanel + public interface INavigableContainer { /// /// Gets the next control in the specified direction. @@ -19,6 +17,6 @@ namespace Perspex.Controls /// The movement direction. /// The control from which movement begins. /// The control. - IControl GetControl(FocusNavigationDirection direction, IControl from); + IInputElement GetControl(FocusNavigationDirection direction, IInputElement from); } } diff --git a/Perspex.Input/KeyboardNavigation.cs b/Perspex.Input/KeyboardNavigation.cs index 23297ca24b..f0f0c94ac8 100644 --- a/Perspex.Input/KeyboardNavigation.cs +++ b/Perspex.Input/KeyboardNavigation.cs @@ -11,6 +11,19 @@ namespace Perspex.Input /// public static class KeyboardNavigation { + /// + /// Defines the DirectionalNavigation attached property. + /// + /// + /// The DirectionalNavigation attached property defines how pressing arrow keys causes + /// focus to be navigated between the children of the container. + /// + public static readonly PerspexProperty DirectionalNavigationProperty = + PerspexProperty.RegisterAttached( + "DirectionalNavigation", + typeof(KeyboardNavigation), + KeyboardNavigationMode.None); + /// /// Defines the TabNavigation attached property. /// @@ -19,7 +32,9 @@ namespace Perspex.Input /// be navigated between the children of the container. /// public static readonly PerspexProperty TabNavigationProperty = - PerspexProperty.RegisterAttached("TabNavigation", typeof(KeyboardNavigation)); + PerspexProperty.RegisterAttached( + "TabNavigation", + typeof(KeyboardNavigation)); /// /// Defines the TabOnceActiveElement attached property. @@ -30,7 +45,29 @@ namespace Perspex.Input /// defines to which child the focus should move. /// public static readonly PerspexProperty TabOnceActiveElementProperty = - PerspexProperty.RegisterAttached("TabOnceActiveElement", typeof(KeyboardNavigation)); + PerspexProperty.RegisterAttached( + "TabOnceActiveElement", + typeof(KeyboardNavigation)); + + /// + /// Gets the for a container. + /// + /// The container. + /// The for the container. + public static KeyboardNavigationMode GetDirectionalNavigation(InputElement element) + { + return element.GetValue(DirectionalNavigationProperty); + } + + /// + /// Sets the for a container. + /// + /// The container. + /// The for the container. + public static void SetDirectionalNavigation(InputElement element, KeyboardNavigationMode value) + { + element.SetValue(DirectionalNavigationProperty, value); + } /// /// Gets the for a container. diff --git a/Perspex.Input/KeyboardNavigationHandler.cs b/Perspex.Input/KeyboardNavigationHandler.cs index b8891da8a0..f33913843b 100644 --- a/Perspex.Input/KeyboardNavigationHandler.cs +++ b/Perspex.Input/KeyboardNavigationHandler.cs @@ -43,11 +43,17 @@ namespace Perspex.Input } /// - /// Gets the next element in tab order. + /// Gets the next control in the specified navigation direction. /// /// The element. - /// The next element in tab order. - public static IInputElement GetNextInTabOrder(IInputElement element) + /// The navigation direction. + /// + /// The next element in the specified direction, or null if + /// was the last in therequested direction. + /// + public static IInputElement GetNext( + IInputElement element, + FocusNavigationDirection direction) { Contract.Requires(element != null); @@ -55,60 +61,39 @@ namespace Perspex.Input if (container != null) { - var mode = KeyboardNavigation.GetTabNavigation((InputElement)container); + KeyboardNavigationMode mode; - switch (mode) + if (direction == FocusNavigationDirection.Next || direction == FocusNavigationDirection.Previous) { - case KeyboardNavigationMode.Continue: - return GetNextInContainer(element, container) ?? - GetFirstInNextContainer(container); - case KeyboardNavigationMode.Cycle: - return GetNextInContainer(element, container) ?? - GetDescendents(container).FirstOrDefault(); - case KeyboardNavigationMode.Contained: - return GetNextInContainer(element, container); - default: - return GetFirstInNextContainer(container); + mode = KeyboardNavigation.GetTabNavigation((InputElement)container); + } + else + { + mode = KeyboardNavigation.GetDirectionalNavigation((InputElement)container); } - } - else - { - return GetDescendents(element).FirstOrDefault(); - } - } - - /// - /// Gets the next element in tab order. - /// - /// The element. - /// The next element in tab order. - public static IInputElement GetPreviousInTabOrder(IInputElement element) - { - Contract.Requires(element != null); - - var container = element.GetVisualParent(); - if (container != null) - { - var mode = KeyboardNavigation.GetTabNavigation((InputElement)container); + bool forward = direction == FocusNavigationDirection.Next || + direction == FocusNavigationDirection.Last || + direction == FocusNavigationDirection.Right || + direction == FocusNavigationDirection.Down; switch (mode) { case KeyboardNavigationMode.Continue: - return GetPreviousInContainer(element, container) ?? - GetLastInPreviousContainer(element); + return GetNextInContainer(element, container, direction) ?? + GetFirstInNextContainer(element, forward); case KeyboardNavigationMode.Cycle: - return GetPreviousInContainer(element, container) ?? - GetDescendents(container).LastOrDefault(); + return GetNextInContainer(element, container, direction) ?? + GetDescendent(container, forward); case KeyboardNavigationMode.Contained: - return GetPreviousInContainer(element, container); + return GetNextInContainer(element, container, direction); default: - return GetLastInPreviousContainer(container); + return GetFirstInNextContainer(container, forward); } } else { - return GetDescendents(element).LastOrDefault(); + return GetDescendents(element).FirstOrDefault(); } } @@ -120,7 +105,7 @@ namespace Perspex.Input { Contract.Requires(element != null); - var next = GetNextInTabOrder(element); + var next = GetNext(element, FocusNavigationDirection.Next); if (next != null) { @@ -136,7 +121,7 @@ namespace Perspex.Input { Contract.Requires(element != null); - var next = GetPreviousInTabOrder(element); + var next = GetNext(element, FocusNavigationDirection.Previous); if (next != null) { @@ -158,6 +143,19 @@ namespace Perspex.Input /// True if a descendent of the element can be focused. private static bool CanFocusDescendent(IInputElement e) => e.IsEnabledCore && e.IsVisible; + /// + /// Gets the first or last focusable descendent of the specified element. + /// + /// The element. + /// Whether to search forward or backwards. + /// The element or null if not found.## + private static IInputElement GetDescendent(IInputElement container, bool forward) + { + return forward ? + GetDescendents(container).FirstOrDefault() : + GetDescendents(container).LastOrDefault(); + } + /// /// Gets the focusable descendents of the specified element, depending on the element's /// . @@ -212,8 +210,12 @@ namespace Perspex.Input /// /// The starting element/ /// The container. + /// The direction. /// The next element, or null if the element is the last. - private static IInputElement GetNextInContainer(IInputElement element, IInputElement container) + private static IInputElement GetNextInContainer( + IInputElement element, + IInputElement container, + FocusNavigationDirection direction) { var descendent = GetDescendents(element).FirstOrDefault(); @@ -223,98 +225,54 @@ namespace Perspex.Input } else if (container != null) { - var sibling = container.GetVisualChildren() - .OfType() - .Where(CanFocus) - .SkipWhile(x => x != element) - .Skip(1) - .FirstOrDefault(); + var navigable = container as INavigableContainer; - if (sibling != null) + // TODO: Do a spatial search here. + if (navigable != null) { - return sibling; + while (element != null) + { + var sibling = navigable.GetControl(direction, element); + + if (sibling != null && CanFocus(sibling)) + { + return sibling; + } + + element = sibling; + } } } return null; } - /// - /// Gets the previous item that should be focused in the specified container. - /// - /// The starting element/ - /// The container. - /// The previous element, or null if the element is the first. - private static IInputElement GetPreviousInContainer(IInputElement element, IInputElement container) - { - return container.GetVisualChildren() - .OfType() - .Where(CanFocus) - .TakeWhile(x => x != element) - .LastOrDefault(); - } - /// /// Gets the first item that should be focused in the next container. /// /// The container. + /// Whether to search forward or backwards. /// The first element, or null if there are no more elements. - private static IInputElement GetFirstInNextContainer(IInputElement container) + private static IInputElement GetFirstInNextContainer(IInputElement container, bool forward) { var parent = container.GetVisualParent(); IInputElement next = null; if (parent != null) { - var sibling = parent.GetVisualChildren() + var siblings = parent.GetVisualChildren() .OfType() - .Where(CanFocusDescendent) - .SkipWhile(x => x != container) - .Skip(1) - .FirstOrDefault(); + .Where(CanFocusDescendent); + IInputElement sibling; - if (sibling != null) + if (forward) { - if (CanFocus(sibling)) - { - next = sibling; - } - else - { - next = GetDescendents(sibling).FirstOrDefault(); - } + sibling = siblings.SkipWhile(x => x != container).Skip(1).FirstOrDefault(); } - - if (next == null) + else { - next = GetFirstInNextContainer(parent); + sibling = siblings.TakeWhile(x => x != container).LastOrDefault(); } - } - else - { - next = GetDescendents(container).FirstOrDefault(); - } - - return next; - } - - /// - /// Gets the last item that should be focused in the previous container. - /// - /// The container. - /// The next element, or null if there are no more elements. - private static IInputElement GetLastInPreviousContainer(IInputElement container) - { - var parent = container.GetVisualParent(); - IInputElement next = null; - - if (parent != null) - { - var sibling = parent.GetVisualChildren() - .OfType() - .Where(CanFocusDescendent) - .TakeWhile(x => x != container) - .LastOrDefault(); if (sibling != null) { @@ -324,18 +282,22 @@ namespace Perspex.Input } else { - next = GetDescendents(sibling).LastOrDefault(); + next = forward ? + GetDescendents(sibling).FirstOrDefault() : + GetDescendents(sibling).LastOrDefault(); } } if (next == null) { - next = GetLastInPreviousContainer(parent); + next = GetFirstInNextContainer(parent, forward); } } else { - next = GetDescendents(container).LastOrDefault(); + next = forward ? + GetDescendents(container).FirstOrDefault() : + GetDescendents(container).LastOrDefault(); } return next; diff --git a/Perspex.Input/Perspex.Input.csproj b/Perspex.Input/Perspex.Input.csproj index dba8e376f6..ab2e219cf1 100644 --- a/Perspex.Input/Perspex.Input.csproj +++ b/Perspex.Input/Perspex.Input.csproj @@ -75,6 +75,7 @@ + diff --git a/Tests/Perspex.Input.UnitTests/KeyboardNavigationTests_Tab.cs b/Tests/Perspex.Input.UnitTests/KeyboardNavigationTests_Tab.cs index 0adfd365e8..6eb06966fb 100644 --- a/Tests/Perspex.Input.UnitTests/KeyboardNavigationTests_Tab.cs +++ b/Tests/Perspex.Input.UnitTests/KeyboardNavigationTests_Tab.cs @@ -12,7 +12,7 @@ namespace Perspex.Input.UnitTests public class KeyboardNavigationTests_Tab { [Fact] - public void GetNextInTabOrder_Continue_Returns_Next_Control_In_Container() + public void Next_Continue_Returns_Next_Control_In_Container() { StackPanel container; Button current; @@ -43,13 +43,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Continue_Returns_First_Control_In_Next_Sibling_Container() + public void Next_Continue_Returns_First_Control_In_Next_Sibling_Container() { StackPanel container; Button current; @@ -80,13 +80,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Continue_Returns_Next_Sibling() + public void Next_Continue_Returns_Next_Sibling() { StackPanel container; Button current; @@ -109,13 +109,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Continue_Returns_First_Control_In_Next_Uncle_Container() + public void Next_Continue_Returns_First_Control_In_Next_Uncle_Container() { StackPanel container; Button current; @@ -152,13 +152,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Continue_Returns_Child_Of_Top_Level() + public void Next_Continue_Returns_Child_Of_Top_Level() { Button next; @@ -170,13 +170,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(top); + var result = KeyboardNavigationHandler.GetNext(top, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Continue_Wraps() + public void Next_Continue_Wraps() { StackPanel container; Button current; @@ -213,13 +213,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Cycle_Returns_Next_Control_In_Container() + public void Next_Cycle_Returns_Next_Control_In_Container() { StackPanel container; Button current; @@ -251,13 +251,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Cycle_Wraps_To_First() + public void Next_Cycle_Wraps_To_First() { StackPanel container; Button current; @@ -289,13 +289,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Contained_Returns_Next_Control_In_Container() + public void Next_Contained_Returns_Next_Control_In_Container() { StackPanel container; Button current; @@ -327,13 +327,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Contained_Stops_At_End() + public void Next_Contained_Stops_At_End() { StackPanel container; Button current; @@ -365,13 +365,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Null(result); } [Fact] - public void GetNextInTabOrder_Once_Moves_To_Next_Container() + public void Next_Once_Moves_To_Next_Container() { StackPanel container; Button current; @@ -403,13 +403,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Once_Moves_To_Active_Element() + public void Next_Once_Moves_To_Active_Element() { StackPanel container; Button current; @@ -443,13 +443,13 @@ namespace Perspex.Input.UnitTests KeyboardNavigation.SetTabOnceActiveElement(container, next); - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Never_Moves_To_Next_Container() + public void Next_Never_Moves_To_Next_Container() { StackPanel container; Button current; @@ -481,13 +481,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetNextInTabOrder_Never_Skips_Container() + public void Next_Never_Skips_Container() { StackPanel container; Button current; @@ -521,13 +521,13 @@ namespace Perspex.Input.UnitTests KeyboardNavigation.SetTabOnceActiveElement(container, next); - var result = KeyboardNavigationHandler.GetNextInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Next); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Continue_Returns_Previous_Control_In_Container() + public void Previous_Continue_Returns_Previous_Control_In_Container() { StackPanel container; Button current; @@ -558,13 +558,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Continue_Returns_Last_Control_In_Previous_Sibling_Container() + public void Previous_Continue_Returns_Last_Control_In_Previous_Sibling_Container() { StackPanel container; Button current; @@ -595,13 +595,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Continue_Returns_Last_Child_Of_Sibling() + public void Previous_Continue_Returns_Last_Child_Of_Sibling() { StackPanel container; Button current; @@ -624,13 +624,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Continue_Returns_Last_Control_In_Previous_Nephew_Container() + public void Previous_Continue_Returns_Last_Control_In_Previous_Nephew_Container() { StackPanel container; Button current; @@ -667,13 +667,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Continue_Wraps() + public void Previous_Continue_Wraps() { StackPanel container; Button current; @@ -710,13 +710,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Cycle_Returns_Previous_Control_In_Container() + public void Previous_Cycle_Returns_Previous_Control_In_Container() { StackPanel container; Button current; @@ -748,13 +748,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Cycle_Wraps_To_Last() + public void Previous_Cycle_Wraps_To_Last() { StackPanel container; Button current; @@ -786,13 +786,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Contained_Returns_Previous_Control_In_Container() + public void Previous_Contained_Returns_Previous_Control_In_Container() { StackPanel container; Button current; @@ -824,13 +824,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Contained_Stops_At_Beginning() + public void Previous_Contained_Stops_At_Beginning() { StackPanel container; Button current; @@ -862,13 +862,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Null(result); } [Fact] - public void GetPreviousInTabOrder_Once_Moves_To_Previous_Container() + public void Previous_Once_Moves_To_Previous_Container() { StackPanel container; Button current; @@ -900,13 +900,13 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Once_Moves_To_Active_Element() + public void Previous_Once_Moves_To_Active_Element() { StackPanel container; Button current; @@ -940,13 +940,13 @@ namespace Perspex.Input.UnitTests KeyboardNavigation.SetTabOnceActiveElement(container, next); - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); } [Fact] - public void GetPreviousInTabOrder_Once_Moves_To_First_Element() + public void Previous_Once_Moves_To_First_Element() { StackPanel container; Button current; @@ -978,7 +978,7 @@ namespace Perspex.Input.UnitTests } }; - var result = KeyboardNavigationHandler.GetPreviousInTabOrder(current); + var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Previous); Assert.Equal(next, result); }