I'm relatively new to Unity and I'm trying to build an in-game reorderable list using the UI Toolkit features.
I'm populating a ListView element with a Visual Tree Asset that is a composite of several Label and Button elements.
I would like to be able to click-and-hold a button (perhaps on the left-side) in the list-item and then drag the list-item, up or down, to the position I want in the list.
I was able to successfully bind the clickable.clicked function to a list-item child Button using the following code:
Action<VisualElement, int> bindItem = (e, i) => {
var reorder_button = e.Q<Button>("reorder_button");
if (reorder_button != null) reorder_button.clickable.clicked += () => ReorderClicked(e);
};
where the function called is:
void ReorderClicked(VisualElement ve)
{
var title = ve.Q<Label>("title");
Debug.Log("Clicked " + title.text);
};
This works as expected but how would I expand on this to accommodate click-and-hold or a mouse-down / mouse-up event?
It was suggested that I use the features in Unity for dragging events but I don't see a way of implementing this in the UI Toolkit framework.
