Skip to content

Commit

Permalink
fix double context request from hold gesture (AvaloniaUI#13948)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmauss authored Dec 14, 2023
1 parent 9bc1ed6 commit 7fe2747
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Avalonia.Controls/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,13 @@ protected sealed override void OnAttachedToVisualTreeCore(VisualTreeAttachmentEv

private void OnHoldEvent(object? sender, HoldingRoutedEventArgs e)
{
if (!e.Handled && e.HoldingState == HoldingState.Started)
if (e.Source == this && !e.Handled && e.HoldingState == HoldingState.Started)
{
// Trigger ContentRequest when hold has started
RaiseEvent(e.PointerEventArgs is { } ev ? new ContextRequestedEventArgs(ev) : new ContextRequestedEventArgs());
var contextEvent = e.PointerEventArgs is { } ev ? new ContextRequestedEventArgs(ev) : new ContextRequestedEventArgs();
RaiseEvent(contextEvent);

e.Handled = contextEvent.Handled;
}
}

Expand Down

0 comments on commit 7fe2747

Please sign in to comment.