On 13/11/2017 at 10:01, xxxxxxxx wrote:
first of all, I need to mention that the Object Manager is actually not a TreeView CustomGUI. There's quite some stuff hard coded internally, so you may not completely succeed in imitating it completely.
But for the drag and drop part (with one small exception) there shouldn't be an issue.
You are already looking at the correct function: AcceptDragObject()
With the return value, you can not only specify, that you will accept or refuse a (or multiple) dragged entities, but also the type of mouse pointer Cinema 4D will display.
By returning one or multiple of the INSERT flags, you will get the "golden lines" to insert objects. But there is another flag, which may be returned additionally or also alone: ACCEPT_DRAG_OBJECT_FORCE_COPY. This will add the "plus" to the mouse pointer. If not combined with any INSERT flags, it's only possible to append to the list.)
So for example, when a material is dragged onto an object, you'd have a combination of INSERT_UNDER and ACCEPT_DRAG_OBJECT_FORCE_COPY. And here's the drawback, the golden line does still appear, and it doesn't in OM.
Then you also want to react to the type of the dragged entities. The dragdata is also passed to AcceptDragObject(). Depending on parameter type, you can inspect the drag data, before returning any of the above flags. For example, all C4DAtom derived entities (objects, materials, tags,...) get dragged as an AtomArray (DRAGTYPE_ATOMARRAY).
So you can do something like this:
Int32 MyTreeViewFuncs::AcceptDragObject(void* root, void* ud, void* obj, Int32 type, void* dragData, Bool& allowCopy)
AtomArray* const arr = static_cast<AtomArray*>(dragData);
const Int32 count = arr->GetCount();
for (Int32 i = 0; i < count; ++i)
C4DAtom* const atom = arr->GetIndex(i);
if (!atom || !atom->IsInstanceOf(Obase))
return 0; // do not accept objects
return INSERT_UNDER | ACCEPT_DRAG_OBJECT_FORCE_COPY;