# Custom Touch Events

**URL:** <https://forums.unrealengine.com/t/custom-touch-events/349291>\
**Category:** C++\
**Tags:** unreal-engine, touch-event, question, CPP\
**Created:** [March 2, 2016, 1:04pm UTC](https://forums.unrealengine.com/t/custom-touch-events/349291 "2016-03-02T13:04:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![giorgk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@giorgk](https://forums.unrealengine.com/u/giorgk)\
**Post date:** [March 2, 2016, 1:04pm UTC](https://forums.unrealengine.com/t/custom-touch-events/349291/1 "2016-03-02T13:04:33Z")

</div>

I’m trying to implement Custom touch events with C++. Here is what I’m doing:  
The header file:

```
UFUNCTION()
void CustomTouchBegin(ETouchIndex::Type type, UPrimitiveComponent* TouchedComponent);
UFUNCTION()
void CustomTouchBegin2(ETouchIndex::Type type);

```

and the implementation file:

```
//in the constructor of my actor Class:
BoardMesh->OnInputTouchBegin.AddDynamic(this, &AMyBoard::CustomTouchBegin);
OnInputTouchBegin.AddDynamic(this, &AMyBoard::CustomTouchBegin2);

//The two events:
void AMyBoard::CustomTouchBegin(ETouchIndex::Type type, UPrimitiveComponent* TouchedComponent) {
	
	GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Blue, TEXT("Somebody touched me"));
}

void AMyBoard::CustomTouchBegin2(ETouchIndex::Type type) {

	GEngine->AddOnScreenDebugMessage(-1, 3.f, FColor::Red, TEXT("Somebody touched me"));
}

```

The CustomTouchBegin2 works fine, and the message appears whenever I touch any component of the AMyBoard class. However the CustomTouchBegin which is supposed to display a message whenever the BoardMesh, (static mesh) is touched is not working.

Besides the above implementation I derived a blueprint class using the AMyBoard as parent and added the PrintScreen node to the OnInputTouchBegin(BoardMesh) node within Blueprints. That also works.

How can I implement the touch events on specific components using C++?

---

<div class="post-metadata">

**Author:** ![giorgk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@giorgk](https://forums.unrealengine.com/u/giorgk)\
**Post date:** [March 3, 2016, 6:28am UTC](https://forums.unrealengine.com/t/custom-touch-events/349291/2 "2016-03-03T06:28:55Z")

</div>

To save other people time:  
There is no error with the code above. The problem was the fact that I had created a blueprint class based on my `AMyBoard` C++ class and placed it in the scene BEFORE I implement the code for handling the touch events. When I placed the C++ class directly in the scene the code worked fine. The code worked also fine when I derived a new blueprint class, and right now I have 2 BP derived from the same C++ class which have different behavior when they should not.

**Therefore the actual question for this issue is whether there is a way to force somehow an existing BP to adapt the changes made on its C++ parent class?**
