Wrong Context Menu when right clicking at AnimNotify Track in 5.7

In 5.7, right clicking on AnimSequence notifies track area intermittently (but often enough) invokes context menu by SAnimTimeline instead of the context menu by SAnimNotifyTrack.

I can’t figure out the exact condition, just know that it can be avoided by left clicking before right click to invoke context menu. So i guess that some invalidation might be missing, but failed to fix on our own and report here as this can be reproducible in vanilla unreal 5.7.

[Image Removed]

One thing that we have figured out is that, SAnimTrackArea::OnMouseButtonUp is get involved when SAnimTimeline menu is unexpectedly invoked.

So, the callstack is like

** When AnimNotifyTrack contenxt menu is invoked as expected:

UnrealEditor-Persona.dll!SAnimNotifyTrack::OnMouseButtonUp(const FGeometry & MyGeometry, const FPointerEvent & MouseEvent) 줄 2666	C++
 	[인라인 프레임] UnrealEditor-Slate.dll!FSlateApplication::RoutePointerUpEvent::__l10::<lambda_3>::operator()(const FArrangedWidget &) 줄 5547	C++
 	UnrealEditor-Slate.dll!FEventRouter::Route<FReply,FEventRouter::FBubblePolicy,FPointerEvent,`FSlateApplication::RoutePointerUpEvent'::`10'::<lambda_3>>(FSlateApplication * ThisApplication, FEventRouter::FBubblePolicy RoutingPolicy, FPointerEvent EventCopy, const FSlateApplication::RoutePointerUpEvent::__l10::<lambda_3> & Lambda, ESlateDebuggingInputEvent DebuggingInputEvent) 줄 459	C++
 	UnrealEditor-Slate.dll!FSlateApplication::RoutePointerUpEvent(const FWidgetPath & WidgetsUnderPointer, const FPointerEvent & PointerEvent) 줄 5523	C++

** When AnimTimeline contenxt menu is invoked as expected:

UnrealEditor-Persona.dll!SAnimTimeline::OnMouseButtonUp(const FGeometry & MyGeometry, const FPointerEvent & MouseEvent) 줄 361	C++
 	[인라인 프레임] UnrealEditor-Slate.dll!FSlateApplication::RoutePointerUpEvent::__l10::<lambda_3>::operator()(const FArrangedWidget &) 줄 5547	C++
 	UnrealEditor-Slate.dll!FEventRouter::Route<FReply,FEventRouter::FBubblePolicy,FPointerEvent,`FSlateApplication::RoutePointerUpEvent'::`10'::<lambda_3>>(FSlateApplication * ThisApplication, FEventRouter::FBubblePolicy RoutingPolicy, FPointerEvent EventCopy, const FSlateApplication::RoutePointerUpEvent::__l10::<lambda_3> & Lambda, ESlateDebuggingInputEvent DebuggingInputEvent) 줄 459	C++
 	UnrealEditor-Slate.dll!FSlateApplication::RoutePointerUpEvent(const FWidgetPath & WidgetsUnderPointer, const FPointerEvent & PointerEvent) 줄 5523	C++

!! When AnimTimeline contenxt menu is invoked unexpected in AnimNotify area (bug) :

>	UnrealEditor-Persona.dll!SAnimTimeline::OnMouseButtonUp(const FGeometry & MyGeometry, const FPointerEvent & MouseEvent) 줄 361	C++
 	UnrealEditor-Persona.dll!FAnimTimeSliderController::OnMouseButtonUp(SWidget & WidgetOwner, const FGeometry & MyGeometry, const FPointerEvent & MouseEvent) 줄 560	C++
 	UnrealEditor-Persona.dll!SAnimTrackArea::OnMouseButtonUp(const FGeometry & MyGeometry, const FPointerEvent & MouseEvent) 줄 161	C++
 	[인라인 프레임] UnrealEditor-Slate.dll!FSlateApplication::RoutePointerUpEvent::__l8::<lambda_2>::operator()(const FArrangedWidget &) 줄 5479	C++
 	UnrealEditor-Slate.dll!FEventRouter::Route<FReply,FEventRouter::FToLeafmostPolicy,FPointerEvent,`FSlateApplication::RoutePointerUpEvent'::`8'::<lambda_2>>(FSlateApplication * ThisApplication, FEventRouter::FToLeafmostPolicy RoutingPolicy, FPointerEvent EventCopy, const FSlateApplication::RoutePointerUpEvent::__l8::<lambda_2> & Lambda, ESlateDebuggingInputEvent DebuggingInputEvent) 줄 459	C++
 	UnrealEditor-Slate.dll!FSlateApplication::RoutePointerUpEvent(const FWidgetPath & WidgetsUnderPointer, const FPointerEvent & PointerEvent) 줄 5465	C++

Thanks !

[Attachment Removed]

Two more things that I have found so far.

1) Removing CaptureMouse call in bHandleRightMouseButton condition block of FAnimTimeSliderController::OnMouseMove fixes this problem. That CaptureMouse calll was added by CL 40277023, to fix another bug, so simply removing CaptureMouse won’t be the final answer.

2) I have tested this in 5.8 preview. It does happen, but a lot less, as like there is no longer a problem.

[Attachment Removed]

Hi, thanks for reporting this. I’ve been able to reproduce the bug, and while I agree that it’s more difficult to reproduce in 5.8, the same bug is still present there.

You’re correct that this issue was caused by the changes in 40277023. The way those changes capture the mouse event during OnMouseMove appear to be too broad. Specifically, the issue is with the following code within the bHandleRightMouseButton branch of AnimTimeSliderController::OnMouseMove:

		if ( DistanceDragged != 0.f )
		{
			DistanceDragged = 0.f;
		
			return FReply::Handled().CaptureMouse(WidgetOwner.AsShared());
		}

That will capture the mouse whenever a right click occurs and there is any movement, even by one pixel. The movement isn’t enough to trigger a pan, but it still captures the mouse input. Then, when the mouse up event occurs, we now are forced to invoke FAnimTimeSliderController::OnMouseButtonUp which in turn triggers the following code:

		if (!bPanning && DistanceDragged == 0.0f)
		{
			return WeakTimeline.Pin()->OnMouseButtonUp(MyGeometry, MouseEvent).ReleaseMouseCapture();
		}

This displays the right click context menu for SAnimTimeline instead of SAnimNotifyTrack.

As I say, I think the change above from 40277023 is overzealous. It should only capture the mouse when a pan is actually occuring. So I would suggest making the following change to FAnimTimeSliderController::OnMouseMove:

			SetViewRange(NewViewOutputMin, NewViewOutputMax, EViewRangeInterpolation::Immediate);
		}
		
// FIX START
		if ( bPanning && DistanceDragged != 0.f )
// FIX END
		{
			DistanceDragged = 0.f;
		
			return FReply::Handled().CaptureMouse(WidgetOwner.AsShared());
		}
	}
	else if (bHandleLeftMouseButton)

This also means that we no longer need the following call in FAnimTimeSliderController::OnMouseButtonUp:

return WeakTimeline.Pin()->OnMouseButtonUp(MyGeometry, MouseEvent).ReleaseMouseCapture();as we now rely on the widgets responding to the mouse up event themselves, rather than having FAnimTimeSliderController capture the mouse interaction.

The feature owner for this code is out this week but I’ll have him review these changes once he’s back next week.

Let me know if you’re able to test the change.

[Attachment Removed]

Great, thanks for confirming that this works for you. I’ll get this submitted once the feature owner is back in office. It’s too late for the 5.8 release now, unfortunately, but it’ll go into the next release after that

[Attachment Removed]

Yes, that makes sense adding bPanning condition.

I have tested with the code as you suggested,

		if ( DistanceDragged != 0.f
// DIFF_BEGIN
			&& bPanning
// DIFF_END
			)
		{
			DistanceDragged = 0.f;		
			return FReply::Handled().CaptureMouse(WidgetOwner.AsShared());
		}

It works correctly on our side.

Thanks for the help!

[Attachment Removed]