Common UI - Keyboard and Mouse

I set mouse capture in my viewport class

void UMyViewport::Init(struct FWorldContext& WorldContext, UGameInstance* OwningGameInstance, bool bCreateNewAudioDevice)
{
	Super::Init(WorldContext, OwningGameInstance, bCreateNewAudioDevice);

	SetMouseCaptureMode(EMouseCaptureMode::NoCapture);
	SetMouseLockMode(EMouseLockMode::LockInFullscreen);
}

And made a FNavigationConfig

class COMPONENTSDEMO_API FUINaviConfig : public FNavigationConfig
{
public:
	FUINaviConfig();
};

UCLASS(minimalapi)
class AComponentsDemoGameMode : public AGameModeBase
{
	GENERATED_BODY()
	
	TSharedRef<FUINaviConfig> NaviConfig;

public:
	AComponentsDemoGameMode();

protected:
	virtual void BeginPlay() override;
};

Here is the cpp file

FUINaviConfig::FUINaviConfig()
{
	// By calling this, default keys would be unbound
	//KeyEventRules.Reset();
	
	KeyEventRules.Emplace(EKeys::A, EUINavigation::Left);
	KeyEventRules.Emplace(EKeys::D, EUINavigation::Right);
	KeyEventRules.Emplace(EKeys::W, EUINavigation::Up);
	KeyEventRules.Emplace(EKeys::S, EUINavigation::Down);

	//KeyActionRules.Reset();
	KeyActionRules.Emplace(EKeys::Enter, EUINavigationAction::Accept);
	//KeyActionRules.Remove(EKeys::SpaceBar);
	KeyActionRules.Emplace(EKeys::BackSpace, EUINavigationAction::Back);
}

AComponentsDemoGameMode::AComponentsDemoGameMode()
: NaviConfig(MakeShared<FUINaviConfig>())
{
	// set default pawn class to our Blueprinted character
	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/ThirdPerson/Blueprints/BP_ThirdPersonCharacter"));
	if (PlayerPawnBPClass.Class != nullptr)
	{
		DefaultPawnClass = PlayerPawnBPClass.Class;
	}
}

void AComponentsDemoGameMode::BeginPlay()
{
	Super::BeginPlay();

	FSlateApplication::Get().SetNavigationConfig(NaviConfig);
}

And I also set input mode in my UCommonActivatableWidget class

TOptional<FUIInputConfig> UKeyboardWidget::GetDesiredInputConfig() const
{
	switch (InputConfig)
	{
	case EWidgetInputMode::GameAndMenu:
		return FUIInputConfig(ECommonInputMode::All, GameMouseCaptureMode);
	case EWidgetInputMode::Game:
		return FUIInputConfig(ECommonInputMode::Game, GameMouseCaptureMode);
	case EWidgetInputMode::Menu:
		return FUIInputConfig(ECommonInputMode::Menu, EMouseCaptureMode::NoCapture, EMouseLockMode::DoNotLock);
	case EWidgetInputMode::Default:
	default:
		return TOptional<FUIInputConfig>();
	}

When I push my menu to the stack, mouse cursor still moves and triggers hover event.

  1. How can I disable mouse cursor capture?
  2. I set Enter key as Accept, but still only space bar works, Enter key never works.

Thanks a lot!

Anyone has any idea?