CogImGui: Fix cursor hidden on startup if imgui input is enabled

This commit is contained in:
Arnaud Jamin
2024-01-08 02:40:54 -05:00
parent 56bb628792
commit b2bb2a4de0
@@ -100,7 +100,6 @@ void FCogImguiContext::Initialize()
PlatformApplication->OnDisplayMetricsChanged().AddRaw(this, &FCogImguiContext::OnDisplayMetricsChanged);
OnDisplayMetricsChanged(DisplayMetrics);
}
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -640,6 +639,19 @@ void FCogImguiContext::SetShareMouseWithGameplay(bool Value)
//--------------------------------------------------------------------------------------------------------------------------
void FCogImguiContext::RefreshMouseCursor()
{
//-------------------------------------------------------------------------------------------
// Focus the main widget when enabling input otherwise the mouse can still be hidden because
// the gameplay might have the focus and might hide the cursor.
//-------------------------------------------------------------------------------------------
if (bEnableInput)
{
FSlateApplication::Get().SetKeyboardFocus(MainWidget);
FSlateApplication::Get().SetUserFocus(0, MainWidget);
}
//-------------------------------------------------------------------------------------------
// Force to show the cursor when sharing mouse with gameplay for games that hide the cursor
//-------------------------------------------------------------------------------------------
if (APlayerController* PlayerController = GetLocalPlayerController(GameViewport->GetWorld()))
{
if (bHasSavedInitialCursorVisibility == false)