IDragHandler on child blocks Scrollrect scrolling

Hello,

I’m trying to implement a scrollrect where you can press and hold items to drag them, and before you press and hold, the scrollrect behaves normally. (IDragHandler is on the child object)
But if i Have IDraghandler on the child, you can no longer scroll the Scrollrect by pressing it. How can i fix that?

basically, i want:
The scrollrect to work normally, but when you press and hold an item, the scrollrect stops and the item is dragged

you would need to extend the StandaloneInputModule, override Process and ProcessDrag there and handle your custom scroll-logic inside these methods…
It is not a trivial task.

1 Like

Thanks, I ended up putting a draggable script on an image that takes up half the object, and the other half can scroll. I’ll keep in mind what you said

My approach to this problem would probably be to get rid of the child’s IDragHandler and get rid of the ScrollRect, and instead create my own custom component that detects drags and various other events like PointerDown and implements both of the desired functions depending on what the pointer does.

Something like this should pass control back to the parented ScrollRect

var scrollRect = GetComponentInParent<ScrollRect>();
eventData.pointerDrag = scrollRect.gameObject;
EventSystem.current.SetSelectedGameObject(scrollRect.gameObject);

scrollRect.OnInitializePotentialDrag(eventData);     
scrollRect.OnBeginDrag(eventData);
6 Likes

Awesome! This did the trick! Thanks you.

1 Like