|
|
|
@ -1,3 +1,4 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
@ -1132,5 +1133,97 @@ namespace Avalonia.Input.UnitTests |
|
|
|
|
|
|
|
Assert.Null(result); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Respects_TabIndex_Moving_Forwards() |
|
|
|
{ |
|
|
|
Button start; |
|
|
|
|
|
|
|
var top = new StackPanel |
|
|
|
{ |
|
|
|
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, |
|
|
|
Children = |
|
|
|
{ |
|
|
|
new StackPanel |
|
|
|
{ |
|
|
|
Children = |
|
|
|
{ |
|
|
|
new Button { Name = "Button1", TabIndex = 5 }, |
|
|
|
(start = new Button { Name = "Button2", TabIndex = 2 }), |
|
|
|
new Button { Name = "Button3", TabIndex = 1 }, |
|
|
|
} |
|
|
|
}, |
|
|
|
new StackPanel |
|
|
|
{ |
|
|
|
Children = |
|
|
|
{ |
|
|
|
new Button { Name = "Button4", TabIndex = 3 }, |
|
|
|
new Button { Name = "Button5", TabIndex = 6 }, |
|
|
|
new Button { Name = "Button6", TabIndex = 4 }, |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var result = new List<string>(); |
|
|
|
var current = (IInputElement)start; |
|
|
|
|
|
|
|
do |
|
|
|
{ |
|
|
|
result.Add(((IControl)current).Name); |
|
|
|
current = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Next); |
|
|
|
} while (current is object && current != start); |
|
|
|
|
|
|
|
Assert.Equal(new[] |
|
|
|
{ |
|
|
|
"Button2", "Button4", "Button6", "Button1", "Button5", "Button3" |
|
|
|
}, result); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Respects_TabIndex_Moving_Backwards() |
|
|
|
{ |
|
|
|
Button start; |
|
|
|
|
|
|
|
var top = new StackPanel |
|
|
|
{ |
|
|
|
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, |
|
|
|
Children = |
|
|
|
{ |
|
|
|
new StackPanel |
|
|
|
{ |
|
|
|
Children = |
|
|
|
{ |
|
|
|
new Button { Name = "Button1", TabIndex = 5 }, |
|
|
|
(start = new Button { Name = "Button2", TabIndex = 2 }), |
|
|
|
new Button { Name = "Button3", TabIndex = 1 }, |
|
|
|
} |
|
|
|
}, |
|
|
|
new StackPanel |
|
|
|
{ |
|
|
|
Children = |
|
|
|
{ |
|
|
|
new Button { Name = "Button4", TabIndex = 3 }, |
|
|
|
new Button { Name = "Button5", TabIndex = 6 }, |
|
|
|
new Button { Name = "Button6", TabIndex = 4 }, |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var result = new List<string>(); |
|
|
|
var current = (IInputElement)start; |
|
|
|
|
|
|
|
do |
|
|
|
{ |
|
|
|
result.Add(((IControl)current).Name); |
|
|
|
current = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Previous); |
|
|
|
} while (current is object && current != start); |
|
|
|
|
|
|
|
Assert.Equal(new[] |
|
|
|
{ |
|
|
|
"Button2", "Button3", "Button5", "Button1", "Button6", "Button4" |
|
|
|
}, result); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|