Browse Source
Track TabIndex value in NumericUpDown (#19348)
* Track TabIndex value in NumericUpDown
* Use template
* Add TabNavigationProperty.OverrideDefaultValue
pull/19469/head
Tim Miller
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
19 additions and
0 deletions
-
src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
-
tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs
|
|
|
@ -379,6 +379,7 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
FocusableProperty.OverrideDefaultValue<NumericUpDown>(true); |
|
|
|
IsTabStopProperty.OverrideDefaultValue<NumericUpDown>(false); |
|
|
|
KeyboardNavigation.TabNavigationProperty.OverrideDefaultValue<NumericUpDown>(KeyboardNavigationMode.Local); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
@ -408,6 +409,7 @@ namespace Avalonia.Controls |
|
|
|
if (TextBox != null) |
|
|
|
{ |
|
|
|
TextBox.Text = Text; |
|
|
|
TextBox[!TabIndexProperty] = this[!TabIndexProperty]; |
|
|
|
TextBox.PointerPressed += TextBoxOnPointerPressed; |
|
|
|
_textBoxTextChangedSubscription = TextBox.GetObservable(TextBox.TextProperty).Subscribe(txt => TextBoxOnTextChanged()); |
|
|
|
} |
|
|
|
|
|
|
|
@ -152,5 +152,22 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
}.RegisterInNameScope(scope); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void TabIndex_Should_Be_Synchronized_With_Inner_TextBox() |
|
|
|
{ |
|
|
|
RunTest((control, textbox) => |
|
|
|
{ |
|
|
|
// Set TabIndex on NumericUpDown
|
|
|
|
control.TabIndex = 5; |
|
|
|
|
|
|
|
// The inner TextBox should inherit the same TabIndex
|
|
|
|
Assert.Equal(5, textbox.TabIndex); |
|
|
|
|
|
|
|
// Change TabIndex and verify it gets synchronized
|
|
|
|
control.TabIndex = 10; |
|
|
|
Assert.Equal(10, textbox.TabIndex); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|