Browse Source
Merge branch 'master' into textInputMethodClientRework
pull/11848/head
Dan Walmsley
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
46 additions and
1 deletions
-
src/Avalonia.Controls/ListBox.cs
-
tests/Avalonia.Controls.UnitTests/ListBoxTests.cs
|
|
|
@ -148,7 +148,7 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
else if (e.Key == Key.Space || e.Key == Key.Enter) |
|
|
|
{ |
|
|
|
e.Handled |= UpdateSelectionFromEventSource( |
|
|
|
UpdateSelectionFromEventSource( |
|
|
|
e.Source, |
|
|
|
true, |
|
|
|
e.KeyModifiers.HasFlag(KeyModifiers.Shift), |
|
|
|
|
|
|
|
@ -1247,6 +1247,51 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
data.GetRealizedItems()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Should_Not_Handle_Space_When_TextBox_Inside_ListBoxItem() |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(TestServices.RealFocus)) |
|
|
|
{ |
|
|
|
var target = new TextBox |
|
|
|
{ |
|
|
|
Focusable = true |
|
|
|
}; |
|
|
|
var listbox = new ListBox() |
|
|
|
{ |
|
|
|
Template = ListBoxTemplate(), |
|
|
|
Items = |
|
|
|
{ |
|
|
|
new ListBoxItem() |
|
|
|
{ |
|
|
|
Template = ListBoxItemTemplate(), |
|
|
|
Content = target, |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var nKeyDown = 0; |
|
|
|
|
|
|
|
var root = new TestRoot() |
|
|
|
{ |
|
|
|
Width = 1000, |
|
|
|
Height = 1000, |
|
|
|
Child = listbox, |
|
|
|
}; |
|
|
|
|
|
|
|
root.KeyDown += (s, e) => nKeyDown++; |
|
|
|
|
|
|
|
|
|
|
|
listbox.ApplyTemplate(); |
|
|
|
root.LayoutManager.ExecuteInitialLayoutPass(); |
|
|
|
|
|
|
|
target.Focus(); |
|
|
|
|
|
|
|
RaiseKeyEvent(target, Key.Space, KeyModifiers.None); |
|
|
|
|
|
|
|
Assert.Equal(1, nKeyDown); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static void RaiseKeyEvent(Control target, Key key, KeyModifiers inputModifiers = 0) |
|
|
|
{ |
|
|
|
target.RaiseEvent(new KeyEventArgs |
|
|
|
|