I’m looking at the code for FSceneViewport::OnMouseButtonDown(). But I have a question about following code.
Why is FViewportClient::InputKey() supposed to run regardless of MouseCaptureMode only when the right mouse button is pressed?
const bool bTemporaryCapture = ViewportClient->GetMouseCaptureMode() == EMouseCaptureMode::CaptureDuringMouseDown || (ViewportClient->GetMouseCaptureMode() == EMouseCaptureMode::CaptureDuringRightMouseDown && InMouseEvent.GetEffectingButton() == EKeys::RightMouseButton);
// Process primary input if we aren't currently a game viewport, we already have capture, or we are permanent capture that doesn't consume the mouse down.
const bool bProcessInputPrimary = !IsCurrentlyGameViewport() || HasMouseCapture() || (ViewportClient->GetMouseCaptureMode() == EMouseCaptureMode::CapturePermanently_IncludingInitialMouseDown);
const bool bAnyMenuWasVisible = FSlateApplication::Get().AnyMenusVisible();
// Process the mouse event
if (bTemporaryCapture || bProcessInputPrimary)
{
if (!ViewportClient->InputKey(FInputKeyEventArgs(this, InMouseEvent.GetUserIndex(), InMouseEvent.GetEffectingButton(), IE_Pressed, 1.0f, InMouseEvent.IsTouchEvent())))
{
CurrentReplyState = FReply::Unhandled();
}
}
Additionally, I also looked at the code in FSceneViewport::OnMouseButtonUp().
Even here, It run FViewportClient::InputKey() regardless of MouseCaptureMode.
I think when it’s MouseCaptureMode::NoCapture, It shouldn’t run InputKey() for all mouse button inputs.