Enable mercy drag between two trees, otherwise disable

Hello,

I have two trees. When dragging and dropping within a tree, I want the item I’m dragging to move (not copy). To achieve this, I disable mercy drag.

However, when dragging and dropping from one tree to the other, I want the item to be copied, so that it remains in the source tree.

I assume I can somehow achieve this by attaching events onDrag and onDrop to the two trees, but I’m not sure how I can tell the source tree not to delete the item being dragged. How can I achieve this?

Thanks!

Hello
You need to use the next approach:

tree.setOnDragIn(my_func); function my_func(dId,lId,sObject,tObject) { if (sObject == tObject){ tree.enableMercyDrag(1); return true; } else { tree.enableMercyDrag(0); } }

That got me headed in the right direction, though it did not work. Both trees must set setOnDragIn, and the function must return true. This works:

function configureMercyDrag(dId, lId, sObject, tObject) {
    if (sObject == tObject) {
        sObject.enableMercyDrag(false);
    }
    else {
        sObject.enableMercyDrag(true);
        tObject.enableMercyDrag(true);
    }
    return true;
}

treeA.setOnDragIn(configureMercyDrag);
treeB.setOnDragIn(configureMercyDrag);

Thanks.

I’ve got you just one tree desigion, and you added more yourself. :slight_smile: