# Enhanced Input not working with CommonUI

**URL:** <https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485>\
**Category:** Programming & Scripting\
**Tags:** UE-5, Input, unreal-engine, UI, question, Blueprint, CPP\
**Created:** [June 17, 2023, 7:38pm UTC](https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485 "2023-06-17T19:38:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Estrange](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Estrange](https://forums.unrealengine.com/u/Estrange)\
**Post date:** [June 17, 2023, 7:38pm UTC](https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485/1 "2023-06-17T19:38:41Z")

</div>

My game is a VN-style game so it is mostly UMG widgets (CommonUI).  
When said widgets are on screen, my IAs no longer work.  
I can see the context is loaded in the Enhanced Input debug, but nothing happens when I press a key.  
Any ideas on what to try would be appreciated!!!

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [June 17, 2023, 7:44pm UTC](https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485/2 "2023-06-17T19:44:24Z")

</div>

I think you should update the input mode

> UWidgetBlueprintLibrary::SetInputMode\_GameAndUI();  
> UWidgetBlueprintLibrary::SetInputMode\_GameOnly();  
> UWidgetBlueprintLibrary::SetInputMode\_UIOnly();

---

<div class="post-metadata">

**Author:** ![Estrange](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Estrange](https://forums.unrealengine.com/u/Estrange)\
**Post date:** [June 17, 2023, 8:10pm UTC](https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485/3 "2023-06-17T20:10:05Z")

</div>

I’ve tried every input mode.  
GameOnly works until I click the widget.  
I’m guessing CommonUI is setting it to a mode that blocks input?

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [June 17, 2023, 8:26pm UTC](https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485/4 "2023-06-17T20:26:56Z")

</div>

try this:

> APlayerController::APlayerController(const FObjectInitializer& ObjectInitializer): Super(ObjectInitializer)
> 
> {   
> PrimaryActorTick.bCanEverTick = true;  
> bEnableMotionControls = true;  
> AutoReceiveInput = EAutoReceiveInput::Type::Disabled;  
> InputPriority = 0;  
> bBlockInput = false;   
> bNetLoadOnClient = true;   
> }

and

> SetFocusable(false); //in your widget bluprint

---

<div class="post-metadata">

**Author:** ![Estrange](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Estrange](https://forums.unrealengine.com/u/Estrange)\
**Post date:** [June 17, 2023, 9:01pm UTC](https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485/5 "2023-06-17T21:01:24Z")

</div>

No difference sadly…  
After reading [this](https://forums.unrealengine.com/t/set-input-mode-game-ui-with-common-ui-plugin/747936/3).  
I might have to stop using “CommonActivatbleWidget”

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [June 17, 2023, 9:07pm UTC](https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485/6 "2023-06-17T21:07:28Z")

</div>

I had the same problem two weeks ago.  
I managed to solve it.  
But don’t post the solution.

I’ve been looking for a while in my code to see what the hell I did but I can’t remember.

What I do know is that I was right… it was a conflict between the focus and the input mode.

If I find the solution I will come back

* * *

> [@Conflict between Focus and InputMode (HUD + Widget + Input) C++](https://forums.unrealengine.com/t/conflict-between-focus-and-inputmode-hud-widget-input-c/1190886):
>
> I think there is a conflict between the Focus of the widget that I use in the HUD and the InputMode. I think when I do the first click the widget captures the focus and then my character loses the ability to rotate. (Unless I hold down a mouse button). I tried to disable the focus but nothing changes. And also a warning appears. This is the current Widget configuration: [2] I’m using the new Enhanced Input system… What I can do? Thank you so much!!

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [June 17, 2023, 9:38pm UTC](https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485/7 "2023-06-17T21:38:32Z")

</div>

i found this:

> void APlayerController::BeginPlay()  
> {  
> Super::BeginPlay();   
> if(InputComponent!=nullptr)  
> {  
> const FInputModeDataBase &InData = FInputModeGameAndUI();  
> SetInputMode(InData);
> 
> }  
> }

> AHUD::AHUD(const FObjectInitializer& ObjectInitializer)  
> : Super(ObjectInitializer)  
> {  
> PrimaryActorTick.bStartWithTickEnabled = false;  
> //SetFocusable();  
> InputPriority = 0;  
> bShowOverlays = true;  
> }

> void ACGamePlayPlayerController::SetupInputComponent()  
> {  
> Super::SetupInputComponent();  
> //EnablePawnInput();  
> bEnableMotionControls = true;  
> OverridePlayerInputClass = UEnhancedInputComponent::StaticClass();  
> AutoReceiveInput = EAutoReceiveInput::Type::Disabled;  
> InputPriority = 0;  
> bBlockInput = false;  
> EnableInput(this);  
> SetShowMouseCursor(false);  
> UWidgetBlueprintLibrary::SetInputMode\_GameOnly(this, false);
> 
> }

> void ACGamePlayPlayerController::BeginPlay()  
> {  
> Super::BeginPlay();   
> SetShowMouseCursor(false);  
> }

> void ACGamePlayPlayerController::DisablePawnInput()  
> {   
> const APawn\* MyPawn = GetPawn();  
> if (MyPawn == nullptr)  
> {   
> return;  
> }  
> if (MyPawn-\>IsLocallyControlled())  
> {  
> DisableInput(this);  
> }  
> }

> void ACGamePlayPlayerController::EnablePawnInput()  
> {   
> const APawn\* MyPawn = GetPawn();  
> if (MyPawn == nullptr)  
> {  
> return;  
> }  
> if (MyPawn-\>IsLocallyControlled())  
> {  
> EnableInput(this);  
> return;  
> }  
> }

I hope you can solve the problem

---

<div class="post-metadata">

**Author:** ![Estrange](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Estrange](https://forums.unrealengine.com/u/Estrange)\
**Post date:** [June 18, 2023, 8:23pm UTC](https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485/8 "2023-06-18T20:23:41Z")

</div>

The problem here is “CommonActivatableWidget”.  
It sets the game input mode on activation.

Extending the class as they did in Lyra is a workaround for this.  
h file:

```auto
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CommonActivatableWidget.h"

#include "LyraActivatableWidget.generated.h"

struct FUIInputConfig;

UENUM(BlueprintType)
enum class ELyraWidgetInputMode : uint8
{
	Default,
	GameAndMenu,
	Game,
	Menu
};

// An activatable widget that automatically drives the desired input config when activated
UCLASS(Abstract, Blueprintable)
class ULyraActivatableWidget : public UCommonActivatableWidget
{
	GENERATED_BODY()

public:
	ULyraActivatableWidget(const FObjectInitializer& ObjectInitializer);
	
public:
	
	//~UCommonActivatableWidget interface
	virtual TOptional<FUIInputConfig> GetDesiredInputConfig() const override;
	//~End of UCommonActivatableWidget interface

#if WITH_EDITOR
	virtual void ValidateCompiledWidgetTree(const UWidgetTree& BlueprintWidgetTree, class IWidgetCompilerLog& CompileLog) const override;
#endif
	
protected:
	/** The desired input mode to use while this UI is activated, for example do you want key presses to still reach the game/player controller? */
	UPROPERTY(EditDefaultsOnly, Category = Input)
	ELyraWidgetInputMode InputConfig = ELyraWidgetInputMode::Default;

	/** The desired mouse behavior when the game gets input. */
	UPROPERTY(EditDefaultsOnly, Category = Input)
	EMouseCaptureMode GameMouseCaptureMode = EMouseCaptureMode::CapturePermanently;
};

```

cpp file:

```auto
// Copyright Epic Games, Inc. All Rights Reserved.

#include "LyraActivatableWidget.h"

#include "Editor/WidgetCompilerLog.h"

#include UE_INLINE_GENERATED_CPP_BY_NAME(LyraActivatableWidget)

#define LOCTEXT_NAMESPACE "Lyra"

ULyraActivatableWidget::ULyraActivatableWidget(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
}

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

#if WITH_EDITOR

void ULyraActivatableWidget::ValidateCompiledWidgetTree(const UWidgetTree& BlueprintWidgetTree, class IWidgetCompilerLog& CompileLog) const
{
	Super::ValidateCompiledWidgetTree(BlueprintWidgetTree, CompileLog);

	if (!GetClass()->IsFunctionImplementedInScript(GET_FUNCTION_NAME_CHECKED(ULyraActivatableWidget, BP_GetDesiredFocusTarget)))
	{
		if (GetParentNativeClass(GetClass()) == ULyraActivatableWidget::StaticClass())
		{
			CompileLog.Warning(LOCTEXT("ValidateGetDesiredFocusTarget_Warning", "GetDesiredFocusTarget wasn't implemented, you're going to have trouble using gamepads on this screen."));
		}
		else
		{
			//TODO - Note for now, because we can't guarantee it isn't implemented in a native subclass of this one.
			CompileLog.Note(LOCTEXT("ValidateGetDesiredFocusTarget_Note", "GetDesiredFocusTarget wasn't implemented, you're going to have trouble using gamepads on this screen. If it was implemented in the native base class you can ignore this message."));
		}
	}
}

#endif

#undef LOCTEXT_NAMESPACE

```

EDIT: Also, you can add a “false” to the end of the inputconfig function calls (its true by default) if you don’t want the mouse disappearing on capture.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [July 18, 2023, 8:24pm UTC](https://forums.unrealengine.com/t/enhanced-input-not-working-with-commonui/1202485/9 "2023-07-18T20:24:09Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
