Touch Scrolling with UMG

I am currently working on a game for mobile and have it so that there is a scrollbox on the level select screen (in UMG). Using blueprints, I have made it so that the scrollbox can be used by touching and dragging to scroll, thanks to the help of this thread:

My issue is that if I first touch a button to try to scroll, the “button pressed” event intercepts my input, so scrolling does not work. How would I ignore the button presses so that if a finger is moved, scrolling would begin? Then, if a button is tapped, the “button pressed” event fires. An example of what I mean is in the app “Words with Friends” (I’m sure there are many others as well).

On touch/mobile you can use button released instead of button pressed, this allows you to determine if a drag has occurred between pressed and released then therefore do one or the other.

Thanks for the response. If I were to use “button released” how would I be able to tell if there was finger movement from “button pressed” to “button released?” UMG widgets don’t have the “touch input” event that can detect when a finger is on the screen.

I saw the overridable functions “OnTouchStarted”, “OnTouchEnded”, and “OnTouchMoved” in the widget blueprint. These seem to have the same problem as above, where they will not be called if my first touch is on a button. From these OnTouch events I am able to “GetScreenSpacePosition” of the touch, so is it possible to somehow have these functions be called when a button’s “onpressed” event is called? Then, if there is no movement detected, I would use “onreleased” to call the button’s functionality.

Have you set the Interaction on you button to Precise Click/Tap?

2 Likes

That’s exactly what I needed, thanks!

Whoo! glad I could help :slight_smile:

Thank you man!It also sloved my problem~ :wink:

The link is dead, can you re-upload, please? Thank you!

Hope this helps, select the button and reach for click, then in the Click Method dropdown you can choose Precise Click

1 Like

For those who are for look for something similar for mobile, under button’s interaction category, you can also find a setting labelled ‘Touch Method’, set it to ‘Precise Touch’. You should be able to scroll over the buttons now.

image

1 Like