# Widget component created by "Add component by class" doesn't receive input even though set "bReceiveHardwareInput" to true

**URL:** <https://forums.unrealengine.com/t/widget-component-created-by-add-component-by-class-doesnt-receive-input-even-though-set-breceivehardwareinput-to-true/2253644>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [January 1, 2025, 11:09am UTC](https://forums.unrealengine.com/t/widget-component-created-by-add-component-by-class-doesnt-receive-input-even-though-set-breceivehardwareinput-to-true/2253644 "2025-01-01T11:09:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [January 1, 2025, 11:09am UTC](https://forums.unrealengine.com/t/widget-component-created-by-add-component-by-class-doesnt-receive-input-even-though-set-breceivehardwareinput-to-true/2253644/1 "2025-01-01T11:09:55Z")

</div>

**Goal**

Dynamicly add any number of widget to character BP. The widget should be fixed at certain location of viewport, so it should be attached to camera component.

**Problem**

Widget component created by `Add component by class` doesn’t receive input even though set `bReceiveHardwareInput` to true.

For example, I create a widget with a button and a image, then the buttion doesn’t respond to my mouse.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/7/1/571070c5d508dd432913c4e9be90e6d65c7912a0.jpeg)

`bReceiveHardwareInput` is protected variable so I create a derived class, new a member function to modify it.

```cpp
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/WidgetComponent.h"
#include "MyWidgetComponent.generated.h"

/**
 * 
 */
UCLASS()
class MYPROJECT_API UMyWidgetComponent : public UWidgetComponent
{
	GENERATED_BODY()
	
	UFUNCTION(BlueprintCallable, Category = UserInterface)
	void EnableInput(bool bEnable)
	{
		bReceiveHardwareInput = bEnable;
	}
};

```

**My blueprint**

[https://blueprintue.com/render/jg7chivf/](https://blueprintue.com/render/jg7chivf/)

**A description of my blueprint**

At the `Begin Play event` of character BP, use `Add component by class` node create my derived widget component class, create testing widget, set the testing widget to widget component, call my custom function to set `bReceiveHardwareInput` to true, attach widget component to camera component, set relative transform of widget component.

**My try**

I have checked some thread, such as

[3D Widget Problem: Buttons onclicked does not Work - Programming & Scripting / UI - Epic Developer Community Forums](https://forums.unrealengine.com/t/3d-widget-problem-buttons-onclicked-does-not-work/474553/35)

His problem simply because of he didn’t set `bReceiveHardwareInput` to true.

[3D Widget Component doesn’t register clicks - Programming & Scripting / Blueprint - Epic Developer Community Forums](https://forums.unrealengine.com/t/3d-widget-component-doesnt-register-clicks/550809/2)

His solution about adding collision box doesn’t help.

**My guess**

If I create widget component in BP editor, then everything is fine, it can receive input.

So I think either I did some wrong about creating component, or attach component incorrectly.

**My project on git**

[CheapMeow/UEWidgetComponentAddedNoInput](https://github.com/CheapMeow/UEWidgetComponentAddedNoInput)

**UE version**

5.5.1

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [January 1, 2025, 4:29pm UTC](https://forums.unrealengine.com/t/widget-component-created-by-add-component-by-class-doesnt-receive-input-even-though-set-breceivehardwareinput-to-true/2253644/2 "2025-01-01T16:29:12Z")

</div>

This seems to be working fine with BPs:

- set widget class on the overridden component and enable hardware input:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/e/5/ae5823e8d031803c97e6f0a89de2fa7b81ea74e3.png)

- add it using one of those:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/d/5/cd5eea5b1949a0acc86429a3b5752d8dfb78a31a.png)

No additional nodes are necessary.

* * *

> [@CheapMeow](#):
>
> **UE version**
> 
> 5.5.1

That’s UE v5.3, though.

---

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [January 1, 2025, 4:39pm UTC](https://forums.unrealengine.com/t/widget-component-created-by-add-component-by-class-doesnt-receive-input-even-though-set-breceivehardwareinput-to-true/2253644/3 "2025-01-01T16:39:44Z")

</div>

It works, thank you!  
There must be some work between my `Add component by class` and the solution spawn custom blueprint component which override widget component.  
But that is additional talk.

---

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [January 2, 2025, 2:23am UTC](https://forums.unrealengine.com/t/widget-component-created-by-add-component-by-class-doesnt-receive-input-even-though-set-breceivehardwareinput-to-true/2253644/4 "2025-01-02T02:23:49Z")

</div>

You can simply use “Add Widget Component” node, which seems like specialization of “Add component”.

---

<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:** [February 1, 2025, 2:24am UTC](https://forums.unrealengine.com/t/widget-component-created-by-add-component-by-class-doesnt-receive-input-even-though-set-breceivehardwareinput-to-true/2253644/5 "2025-02-01T02:24:05Z")

</div>

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