How do I set "Receive Hardware Input" for a widget component added at runtime?

Hi, so I have an actor component on my player character through which I’m adding ANOTHER widget component at runtime:


I can’t find the “Receive Hardware Input” variable to set it to true, like in a widget component that’s added manually:

Please help!!

ReceiveHardwareInput is not exposed to blueprint

Just see WidgetComponent class source code, you can find

protected:
	UPROPERTY(EditAnywhere, Category=Interaction)
	bool bReceiveHardwareInput;

There is not a function to modify it, and it is a protected variable, so it is not exposed to blueprint.

But it is UPROPERTY, so you can modify it in property window.

Example usage of bReceiveHardwareInput UPROPERTY

Example blueprint

CreateWidgetComponent posted by anonymous | blueprintUE | PasteBin For Unreal Engine

Host actor where example blueprint lies

Here we prepare a template of WidgetComponent in a existing actor, its bReceiveHardwareInput=true. When we need to add widget component to somebody, attach it to the one who really need it. It is troublesome but don’t need to modify source code. The reason is explained below

Reason of troublesome usage

When level is loaded, all components are registered.
At the WidgetComponent register function, it will call CanReceiveHardwareInput() to determine whether to register a HitTester into viewport.
HitTester is a helper class to call GetHitResultAtScreenPosition() to capture WidgetComponent and the UI clicked. It is called every frame.
If not, the WidgetComponent will not register HitTester, then even though you set bReceiveHardwareInput=true by your custom cpp function, HitTester will not be created again.
So, use CreateComponentByClass to create a WidgetComponent is a bad idea, because the default value of bReceiveHardwareInput is false.
The solution is create a WidgetComponent in blueprint, and set bReceiveHardwareInput=true, then will game init, the WidgetComponent deserialization will read blueprint value. Or create a custom cpp class to derive from WidgetComponent class, override default value of bReceiveHardwareInput=true.