How to release mouse lock for slate menu?

I’m trying to make a simple main menu using Slate; just a ‘start’ and ‘quit’ button for now. I started following this tutorial: . I made a new HUD and gametype, followed the instructions, and have the expected text and buttons on the screen. However, I can’t get the mouse to release in a reasonable manner.

I’ve googled this and found partial solutions, but they’re not quite working as expected.

is one example, I see similar solutions elsewhere. This is my current code:

//MainMenuHUD.cpp
void AMainMenuHUD::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	SAssignNew(MainMenuUI, SMainMenuUI).MainMenuHUD(this);

	if (GEngine->IsValidLowLevel())
	{
		//GEngine->GameViewport->AddViewportWidgetContent(SNew(SWeakWidget).Cursor(EMouseCursor::Default).PossiblyNullContent(MainMenuUI.ToSharedRef()));

		GEngine->GameViewport->AddViewportWidgetContent(SAssignNew(MainMenuUI, SMainMenuUI));
		
		FSlateApplication::Get().SetKeyboardFocus(MainMenuUI.ToSharedRef());
		FSlateApplication::Get().ReleaseMouseCapture();
		//FSlateApplication::Get().SetUserFocus(0, MainMenuUI.ToSharedRef(), EFocusCause::SetDirectly);
	}
}

void AMainMenuHUD::attempt()
{
	GEngine->GameViewport->AddViewportWidgetContent(SNew(SWeakWidget).PossiblyNullContent(MainMenuUI.ToSharedRef()));
	FSlateApplication::Get().SetKeyboardFocus(MainMenuUI.ToSharedRef());

	FSlateApplication::Get().ReleaseMouseCapture();
}


//SMainMenuUI.cpp
FReply SMainMenuUI::OnKeyboardFocusReceived(const FGeometry& MyGeometry, const FKeyboardFocusEvent& InKeyboardFocusEvent)
{
	return FReply::Handled().ReleaseMouseCapture().SetUserFocus(SharedThis(this), EFocusCause::SetDirectly);
}

According to breakpoints, OnKeyboardFocusReceived() is never called. Attempt() is called through a keybinding; it is being called, but does not do anything. The ReleaseMouseCapture() call in Attempt() does work, but not ideally: The first time I press the key, the mouse is released but not made visible. Moving the mouse does not rotate the player camera (which is correct), but there is also no mouse cursor. Clicking anywhere will re-capture the mouse, and pressing the key a second time will also make it visible. The menu then functions properly after this.

The call to ReleaseMouseCapture() in PostInitializeComponents() does nothing. My goal is to start play with the mouse cursor visible, allowing the user to click on the menu buttons. I don’t know if I need to use a different function for initialization, but I haven’t found anything relevant.

How can I begin play with the mouse cursor visible, and ensure that opening a menu mid-game by button press always results in a visible mouse cursor?

Thank you.