UMG Compatibility - Code Changes: SceneViewport.cpp to 4.7

How I’ve implemented

Did this way, luckily from ViewportClient it’s easy to check if we have a PlayerController asking to hide the mouse cursor.

Worked on 4.6.1, the cursor shows on Editor.



FCursorReply FSceneViewport::OnCursorQuery( const FGeometry& MyGeometry, const FPointerEvent& CursorEvent )
{
	// Kills any other check if we have a PlayerController and he's hidding the mouse
	if (ViewportClient && ViewportClient->GetWorld()->GetFirstPlayerController() != NULL)
	{
		if (!ViewportClient->GetWorld()->GetFirstPlayerController()->bShowMouseCursor)
			return FCursorReply::Cursor(EMouseCursor::None);
	}

	if (bCursorHiddenDueToCapture)
	{
		return FCursorReply::Cursor(EMouseCursor::None);
	}

	EMouseCursor::Type MouseCursorToUse = EMouseCursor::Default;

	// If the cursor should be hidden, use EMouseCursor::None,
	// only when in the foreground, or we'll hide the mouse in the window/program above us.
	if( ViewportClient && GetSizeXY() != FIntPoint::ZeroValue  )
	{
		MouseCursorToUse = ViewportClient->GetCursor( this, GetMouseX(), GetMouseY() );		
	}	
	
	// Use the default cursor if there is no viewport client or we dont have focus
	return FCursorReply::Cursor(MouseCursorToUse);
}

1 Like