How do i disable drag input for a TMP input field? (inside a scrollview)

As the title says, when i drag a scroll view and happen to start dragging on an inputfield it just selects the input field and ignores the drag.
Even spent a good hour with chatGPT4 trying to figure this one out but to no success.

Any help would be greatly appreciated.

ok this script work for now, its a little hit or miss on mobile, but it works for now,
just a pain it replaces the origin TMP input field as i have to reapply my references and add the placeholder/text/textarea back in

using UnityEngine;
using UnityEngine.EventSystems;
using TMPro;

public class DraggableInputField : TMP_InputField, IBeginDragHandler, IDragHandler, IEndDragHandler
{
    private bool isDragging = false;

    public void OnBeginDrag(PointerEventData eventData)
    {
        isDragging = true;

        // Disable the input field to prevent it from being selected.
        interactable = false;

        // Trigger the BeginDrag event on the scroll view.
        ExecuteEvents.ExecuteHierarchy(transform.parent.gameObject, eventData, ExecuteEvents.beginDragHandler);
    }

    public void OnDrag(PointerEventData eventData)
    {
        if (isDragging)
        {
            // Trigger the Drag event on the scroll view.
            ExecuteEvents.ExecuteHierarchy(transform.parent.gameObject, eventData, ExecuteEvents.dragHandler);
        }
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        isDragging = false;

        // Enable the input field.
        interactable = true;

        // Trigger the EndDrag event on the scroll view.
        ExecuteEvents.ExecuteHierarchy(transform.parent.gameObject, eventData, ExecuteEvents.endDragHandler);
    }
}
1 Like

I have same problem too