How to disable camera moves (mouse drag) in an editor plugin?

I tried to override FEdMode:

virtual bool DisallowMouseDeltaTracking() const override
{
    return true; // I also tried to return false
}

but the problem is that the cursor stops moving (and gets invisible).

Is it possible to change the camera moves (to make it like in 3Ds max or sketchup)?

I update the mouse position in the Render() function:

void FPBEdMode::Render(const FSceneView* View, FViewport* Viewport, FPrimitiveDrawInterface* PDI)
{
    MousePosition.X = FMath::Clamp(Viewport->GetMouseX(), 0, Viewport->GetSizeXY().X-1);
    MousePosition.Y = FMath::Clamp(Viewport->GetMouseY(), 0, Viewport->GetSizeXY().Y-1);
 }

and I reset the mouse position on mouse release (taken from FoliageEdMode.cpp):

bool FPBEdMode::InputKey(FEditorViewportClient *ViewportClient, FViewport *Viewport, FKey Key, EInputEvent Event)
{
//    UE_LOG(LogTemp, Warning, TEXT("InputKey: key: %s, event: %d"), *Key.ToString(), int(Event));

    if (Event == IE_Released && Key == EKeys::LeftMouseButton)
    {
        Viewport->SetPreCaptureMousePosFromSlateCursor();
    }
}
1 Like