Drag And Drop Without Containerlist

98 views Asked by At

I have been using ContainerList with drag and drop functionality in the past. Since ContainerList has been deprecated I am now trying to use something different. As recommended in the documentation I would like to use just a Container with BoxLayout in the y-axis. However looking into that this seems to be rather difficult, too.

What I am trying to (re-)create ist a list of entries containing with labels and buttons which entries van be sorted by a longPointerPress followed by drag and drop.

In the past I managed to do this by heavily modifying the ContainerList and ContainerList.Entry classes.

But with a Container I cannot see how to do this at all.

As I see it this would involve:

  • creation of a ListEntry component derived from Container and overriding de.sae.tryout.modules.dragdrop.DraggableContainer.getComponentAt(int, int) to always return this to intercept all of the pointer interactions and
  • depending of its state passing through the pointer events to the child components if it is appropriate

Since this seems to me as an inadmissible trick the question: What is the recommended way to display such a sortable list of entries where each entry contains some labels and buttons?

1

There are 1 answers

1
Shai Almog On

Since every entry would be a lead component to make it feel like a container list just using setDraggable(true) on the lead component and setDropTarget(true) on the parent will allow drag and drop.

Notice this won't have the same behavior as you have now with the long pointer press which might be a problem but might not. If this is a problem you can override the drag initialization behavior of the lead component to make it closer to the way it worked.