Browse Source

Select dropdown item on focus.

Arrow keys within the dropdown are handled by the keyboard navigation handler, so detect when this focuses a new item and select it.
pull/1166/head
Steven Kirk 9 years ago
parent
commit
2f48873184
  1. 10
      src/Avalonia.Controls/DropDown.cs

10
src/Avalonia.Controls/DropDown.cs

@ -96,6 +96,16 @@ namespace Avalonia.Controls
this.UpdateSelectionBoxItem(this.SelectedItem);
}
protected override void OnGotFocus(GotFocusEventArgs e)
{
base.OnGotFocus(e);
if (!e.Handled && e.NavigationMethod == NavigationMethod.Directional)
{
e.Handled = UpdateSelectionFromEventSource(e.Source);
}
}
/// <inheritdoc/>
protected override void OnKeyDown(KeyEventArgs e)
{

Loading…
Cancel
Save