# Input Touch Events over Scroll Box doesn't check if a touch drag is released

**URL:** <https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505>\
**Category:** UI\
**Tags:** bug, scrollbox, unreal-engine, Blueprint, question\
**Created:** [December 6, 2016, 3:46pm UTC](https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505 "2016-12-06T15:46:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xaser3D](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xaser3D](https://forums.unrealengine.com/u/Xaser3D)\
**Post date:** [December 6, 2016, 3:46pm UTC](https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505/1 "2016-12-06T15:46:38Z")

</div>

I found an error input touch event in blueprint over scrollbox doesn’t check if a touch drag is released. Only check if a dragging released outside of the scrollbox. Get input touch state under the scroll box returns x y position only for the first touch and variables x y are not updated during drag. Please Help.

 ![117611-2222.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/5/2456e67d24df9e9c9d36db420fcc4215533f7402.jpeg)

 ![117612-futer.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/6/aa6fdf3ab424186dc3abd479b058fa11f1a4d569.jpeg)

---

<div class="post-metadata">

**Author:** ![Xaser3D](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xaser3D](https://forums.unrealengine.com/u/Xaser3D)\
**Post date:** [December 16, 2016, 7:48am UTC](https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505/2 "2016-12-16T07:48:35Z")

</div>

I hope someone has a solution for this.

---

<div class="post-metadata">

**Author:** ![RVillani](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rvillani/32/1194572_2.png) [@RVillani](https://forums.unrealengine.com/u/RVillani)\
**Post date:** [January 30, 2017, 10:13pm UTC](https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505/3 "2017-01-30T22:13:28Z")

</div>

I’m having the same problem. My camera controls are multi touch. But if my UMG has a ScrollBox, it stucks my controls as if one touch is always on the screen, because the ScrollBox doesn’t consume the “Pressed” event but does so with the “Released”. So, for the game, it’s like I’ve touched the screen and never let go.

---

<div class="post-metadata">

**Author:** ![RVillani](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rvillani/32/1194572_2.png) [@RVillani](https://forums.unrealengine.com/u/RVillani)\
**Post date:** [January 31, 2017, 12:02am UTC](https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505/4 "2017-01-31T00:02:24Z")

</div>

Found this at Engine/Source/Runtime/Slate/Private/Widgets/Layout/ **SScollBox.cpp:825**

```
FReply SScrollBox::OnTouchStarted(const FGeometry& MyGeometry, const FPointerEvent& InTouchEvent)
{    
	return FReply::Unhandled();
}

```

For the other two touch events (Moved/Ended), it always returns _FReply::Handled()_.

I’ll try fixing it by making a custom ScrollBox in C++ extending from this class and UScrollBox. If this works, we won’t have to use the engine source code. I’m not used to the Slate part of UEC++, but this _ **seems** _ an easy fix.

If my fix works, I’ll post the code here. My project is already C++ so it’s not that much of a hassle, but for those who want to use Blueprint only, I tried many workarounds and none worked. ☹

---

<div class="post-metadata">

**Author:** ![RVillani](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rvillani/32/1194572_2.png) [@RVillani](https://forums.unrealengine.com/u/RVillani)\
**Post date:** [January 31, 2017, 5:09am UTC](https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505/5 "2017-01-31T05:09:29Z")

</div>

## C++ Dirty Fix

_By extending the original **SScrollBox** and **UScrollBox** classes, it’s possible to override the method causing the problem and fix it._

Add these modules to Source/YourProjectName/ **YourProjectName.Build.cs** , at **PublicDependencyModuleNames**

```
"SlateCore", "Slate", "UMG"

```

To **YourProjectName.h** , add

```
#include "Engine.h" // already on file
#include "SlateBasics.h" // add this line after that

```

Add these code files to fix the problem on the Slate ScrollBox widget:

### SCustomScrollBox.h

```
#pragma once
#include "Widgets/Layout/SScrollBox.h"

/**
 * Fixes ScrollBox bug of not registering TouchStarted event
 */
class YOURPROJECTNAME_API SCustomScrollBox : public SScrollBox
{
public:
	virtual FReply OnTouchStarted(
		const FGeometry& MyGeometry,
		const FPointerEvent& InTouchEvent) override;
};

```

### SCustomScrollBox.cpp

```
#include "MineSweeper.h"
#include "SCustomScrollBox.h"

FReply SCustomScrollBox::OnTouchStarted(const FGeometry& MyGeometry, const FPointerEvent& InTouchEvent)
{
	return FReply::Handled();
}

```

To be able to use the fixed Slate widget in UMG, also extend the **UScrollBox** class and override the method that creates the Slate widget to use our custom class.

### CustomScrollBox.h

```
#pragma once
#include "UMG.h"
#include "Components/ScrollBox.h"
#include "CustomScrollBox.generated.h"

/**
 * Fixes ScrollBox bug of not registering TouchStarted event
 */
UCLASS()
class YOURPROJECTNAME_API UCustomScrollBox : public UScrollBox
{
	GENERATED_BODY()
protected:
	//~ Begin UWidget Interface
	virtual TSharedRef<SWidget> RebuildWidget() override;
	//~ End UWidget Interface
public:
#if WITH_EDITOR
	//~ Begin UWidget Interface
	virtual const FText GetPaletteCategory() override;
	//~ End UWidget Interface
#endif
};

```

### CustomScrollBox.cpp

```
#include "MineSweeper.h"
#include "SCustomScrollBox.h"
#include "CustomScrollBox.h"

#define LOCTEXT_NAMESPACE "UMG"

TSharedRef<SWidget> UCustomScrollBox::RebuildWidget()
{
	MyScrollBox = SNew(SCustomScrollBox)
		.Style(&WidgetStyle)
		.ScrollBarStyle(&WidgetBarStyle)
		.Orientation(Orientation)
		.ConsumeMouseWheel(ConsumeMouseWheel);

	for (UPanelSlot* PanelSlot : Slots)
	{
		if (UScrollBoxSlot* TypedSlot = Cast<UScrollBoxSlot>(PanelSlot))
		{
			TypedSlot->Parent = this;
			TypedSlot->BuildSlot(MyScrollBox.ToSharedRef());
		}
	}
	return BuildDesignTimeWidget(MyScrollBox.ToSharedRef());
}

#if WITH_EDITOR
const FText UCustomScrollBox::GetPaletteCategory()
{
	return LOCTEXT("User Created", "User Created");
}
#endif

```

This CustomScrollBox will be found in the _User Created_ category of the Palette in the UMG Editor as **Custom Scroll Box**.

As it’s a child of the original ScrollBox, you can safely replace ScrollBoxes and its variables in your Blueprints. Easily replace existing ScrollBoxes in the Design mode by selecting the Custom Scroll Box in the Palette then right clicking on the current ScrollBox in the hierarchy and selecting **Replace With…\>Custom Scroll Box**. The only drawback is that you’ll lose any customization done in the replaced ScrollBox’s Details panel (Style, Visibility etc).

### Don’t forget to replace YOUPROJECTNAME\_API in the code by your project’s API.

---

<div class="post-metadata">

**Author:** ![Xaser3D](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xaser3D](https://forums.unrealengine.com/u/Xaser3D)\
**Post date:** [January 31, 2017, 2:32pm UTC](https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505/6 "2017-01-31T14:32:57Z")

</div>

Hi, RVillani  
I’ve found a solution for my case in blueprint, my menu animation is 0.5 second long so I simply use sequence node and delay for a 0.5 seconds and it works perfect for my particular situation in other cases your approach maybe better. It will be good if Epic fix scrollbox functionality.

---

<div class="post-metadata">

**Author:** ![Xaser3D](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xaser3D](https://forums.unrealengine.com/u/Xaser3D)\
**Post date:** [January 31, 2017, 2:45pm UTC](https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505/7 "2017-01-31T14:45:44Z")

</div>

I found many errors on scrollbox working on my project but I wont lose time explaining in details. Project is ready and I hope to start open beta next month on PlayMarket. Take a look and say what you think.  
[link text](https://www.youtube.com/watch?v=z890yQHvrwQ&t=5s)

[link text](https://www.youtube.com/watch?v=0y8oofyHtLA&t=6s)

---

<div class="post-metadata">

**Author:** ![DraconWhite](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DraconWhite](https://forums.unrealengine.com/u/DraconWhite)\
**Post date:** [April 16, 2018, 9:27am UTC](https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505/8 "2018-04-16T09:27:51Z")

</div>

Hi RVillani,

I’m trying to implement the SCustomScrollBox that inherit from SScrollBox, but I can’t find it. I mean, I can find the class in the project but when I try to create a class from it it doesn’t appear in the panel of UE where you create the class.

Also I’m not sure if I understand the all the code that I have to add to this new custom classes, Can you post the code of the two classes you’ve made?

---

<div class="post-metadata">

**Author:** ![RVillani](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rvillani/32/1194572_2.png) [@RVillani](https://forums.unrealengine.com/u/RVillani)\
**Post date:** [June 22, 2018, 4:42pm UTC](https://forums.unrealengine.com/t/input-touch-events-over-scroll-box-doesnt-check-if-a-touch-drag-is-released/378505/9 "2018-06-22T16:42:36Z")

</div>

Don’t try to extend it in the editor. I believe it doesn’t show slate classes. Create an object class or something and replace the imports, class name etc with the code in my post.
