Skip to main content
Participant
June 22, 2010
Question

How drag and drop a node in a TreeView ?

  • June 22, 2010
  • 2 replies
  • 1280 views

Hi,

I want drag and drop a node in a treeview but i don't know how to get this result. I can drag a page item in a treeview or drag a node in a page item but not a node in another.

Can you help me ?

Regards,

Damien Fontaine

This topic has been closed for replies.

2 replies

Participant
June 23, 2010

I have another problem on drag and drop implementation, how to exchange data between the source and the target ?

I have seen DataExchangeHandler but only for page item. There is other Handler for node in a treeview or i must create it ?

Regards,

Damien Fontaine

Inspiring
June 22, 2010

Hello You need to add DropSource implemetation.

Please look at the BasicDragAndDrop example for more information.

You can also look at the PanelTreeView sample code.

Best regards

/ Pontus

    Class
    {
        kMyNodeWidgetBoss,
        kTreeNodeWidgetBoss,
        {
            /** What the application framework thinks is the  control's event handler */
            IID_IEVENTHANDLER,  kMyNodeEHImpl,
           
      
            /** Observer for changes in node state such as expand/contract */
            IID_IOBSERVER,  kMyNodeObserverImpl,
            
            IID_IDRAGDROPSOURCE,          kMyDragDropSourceImpl, // you need to implemet this
        }
    },

Participant
June 22, 2010

Thanks for you reply,

I have already implement IID_IDRAGDROPSOURCE with :

bool16 EGateDragDropSource::WillDrag(IEvent* event) const

{

return kTrue;

}

bool16 EGateDragDropSource::DoAddDragContent(

  IDragDropController* controller)

{

return kTrue;

}

But when i drag a node in another, my cursor is a circle with a bar prohibiting the drop.

Another_Andrew
Inspiring
June 22, 2010

Your implementation of DoAddDragContent() is a little thin looking.

If you look at the example in the SDK (BscDNDCustomDragSource.cpp) you might need to add at least:

    // we get the data object that represents the drag

    InterfacePtr<IPMDataObject> item(DNDController->AddDragItem(1));

    // no flavor flags

    PMFlavorFlags flavorFlags = 0;

    // we set the type (flavour) in the drag object

    item->PromiseFlavor(customFlavor, flavorFlags);

Also, check that DoAddDragContent()  is actually being called.