Set Input Mode "Game & UI" with Common UI plugin

Thnx you all guys, this topic brought me to the right place and give great starting point! I am working with TopDown setup, Character need move to mouse click position and my widgets need work at this time.
I set in my LyraHUDLayout InputConfig to Game and Menu,
Game Mouse Capture to Capture Durning Mouse Down

and in my LyraActivatableWidget set InputConfig to Menu, Game Mouse Capture to No Capture

This working for me

3 Likes

This is how you can do it:

The HUD and the C++ need to agree that the appropriate Input Mode is All (Game+Menu). And the mouse capture in my case was CapturePermanently_IncludingInitialMouseDown with an invisible mouse, and CaptureDuringMouseDown with a visible mouse.

More info:

Thnx, i was completed task without c++, my solution in my previous post. it’s working great

Does this only work on Lyra? How do I find this “input config” in normal Unreal 5.1?

Tnkx

Unfortunately this is a custom addition by Epic to the CommonUI plugin in Lyra.
In Lyra you can find Input Config in
Widget > Graph Editor Mode > Class Defaults

1 Like

Hi @xi57 time has passed and I am currently on 5.2 preview2. As you said in this version CommonUIActionRouterBase.h has changed and the parameter ActiveInputConfig has been moved to protected:

https://github.com/EpicGames/UnrealEngine/commit/2b34c8ce154011a327087ee7e83fdbb6dacd7907

Also looking at the file the ApplyUIInputConfig is now virtual. So regarding the topic of this thread what should I do to change the behaviour of ApplyUIInputConfig without compiling all the engine. Normally I override the classes and then I use this classes as base for blueprints, but how do i tell the engine to use my custom ApplyUIInputConfig?

There is some Unreal magic going on in the subsystem. During initialization, the subsystem will only initialize if there are no derived classes existing.

See for example:

bool UCommonUIActionRouterBase::ShouldCreateSubsystem(UObject* Outer) const
{
	TArray<UClass*> ChildClasses;
	GetDerivedClasses(GetClass(), ChildClasses, false);

	UE_LOG(LogUIActionRouter, Display, TEXT("Found %i derived classes when attemping to create action router (%s)"), ChildClasses.Num(), *GetClass()->GetName());

	// Only create an instance if there is no override implementation defined elsewhere
	return ChildClasses.Num() == 0;
}

TLDR simply by you deriving a class from UCommonUIActionRouterBase and compiling it into your project, its existence will suppress the base class from initializing, and your class will be used instead.

So all you have to do is derive a child class and implement it. It will “automagically” replace the base subsystem.

1 Like

Thx for your reply, I will try.

1 Like

UE 5.2 is releasing any day now, and I’ve published a new tutorial saying exactly how to take full control over the mouse in Lyra 5.2 (and thereby also CommonUI).

YT vid:

Dev notes:

2 Likes

Sorry if I am not fully caught up with the problem you are trying to solve. I am developing on UE/Lyra 5.1 and I have cases where I want the mouse cursor to be captured but shown.

I noticed in FUIInputConfig there is a variable called bHideCursorDuringViewportCapture and by default it is set to true. Because in its constructor bHideCursorDuringViewportCapture has its default value, no parameter is required for this variable, causing this variable to be true all the time in Lyra.

In my project, I have an ActivatableWidget inheriting from LyraActivatableWidget and added bHideCursorDuringViewportCapture as a custom property. Then in GetDesiredInputConfig function, I simply passed the property to FUIInputConfig’s constructor to set whether the mouse is shown or not.

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

Sorry if I misunderstood the issue you are trying to solve! Just posting it here in case it helps anyone.

I’m trying to use CommonUI (not Lyra) and I watched the whole video. I implemented the C++ function to set the Input Config on the UCommonUIActionRouterBase and I’m still getting the double click problem.

I have no idea what to do.

edit: Ok, I got it working. I didn’t have the main CommonUI widget’s “Is Focusable” set to true. Once I set it to true, it now works.

image
I actually found a solution by just unchecking “Supports Activation Focus” in the widget that im activating, allowing me to still read inputs from legacy input or enhanced input actions when “Game and UI input mode” is active

1 Like

Thank you so much!

I’m working with blueprints (UE 5.3.2), and stumbled upon this easy solution:
image
Untick Enable Default Input Config, and now Set Input Mode function works like it should.
I didn’t check, so I don’t know if this is already documented.

5 Likes

Didn’t seem to help me.

also didnt seem to help me.

Omg again this took me another 1,5h - yes in the end I only needed to uncheck this and it works, that common UI is not catching all input actions.