Browse Source

Merge pull request #3857 from AvaloniaUI/feature/3845-combobox-event-passthrough

Added ComboBox.PopupClosedOverride.
pull/3861/head
Dariusz Komosiński 6 years ago
committed by GitHub
parent
commit
355987ef7f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      src/Avalonia.Controls/ComboBox.cs

22
src/Avalonia.Controls/ComboBox.cs

@ -234,6 +234,23 @@ namespace Avalonia.Controls
base.OnTemplateApplied(e); base.OnTemplateApplied(e);
} }
/// <summary>
/// Called when the ComboBox popup is closed, with the <see cref="PopupClosedEventArgs"/>
/// that caused the popup to close.
/// </summary>
/// <param name="e">The event args.</param>
/// <remarks>
/// This method can be overridden to control whether the event that caused the popup to close
/// is swallowed or passed through.
/// </remarks>
protected virtual void PopupClosedOverride(PopupClosedEventArgs e)
{
if (e.CloseEvent is PointerEventArgs pointerEvent)
{
pointerEvent.Handled = true;
}
}
internal void ItemFocused(ComboBoxItem dropDownItem) internal void ItemFocused(ComboBoxItem dropDownItem)
{ {
if (IsDropDownOpen && dropDownItem.IsFocused && dropDownItem.IsArrangeValid) if (IsDropDownOpen && dropDownItem.IsFocused && dropDownItem.IsArrangeValid)
@ -247,10 +264,7 @@ namespace Avalonia.Controls
_subscriptionsOnOpen?.Dispose(); _subscriptionsOnOpen?.Dispose();
_subscriptionsOnOpen = null; _subscriptionsOnOpen = null;
if (e.CloseEvent is PointerEventArgs pointerEvent) PopupClosedOverride(e);
{
pointerEvent.Handled = true;
}
if (CanFocus(this)) if (CanFocus(this))
{ {

Loading…
Cancel
Save