Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stephen on May 31, 2009 11:59
open dhtmlx forum
dhtmlxTree drag-n-drop or drag-n-copy

How would you recommend implementing providing a user with the choice of drag-n-drop or drag-n-copy?

Eg windows xp
Find the file or folder you want to move.
1 To move drag the file or folder to the destination.
2 To copy the item instead of moving it, press and hold down CTRL while dragging.
Answer posted by Support on Jun 01, 2009 05:29
The small code modification will required to achieve such effect. 
In dhtmlxtree.js you can locate next line 
          if (!this.callEvent("onBeforeDrag",[obj.id])) return null;
and replace it with 
         if (!this.callEvent("onBeforeDrag",[obj.id,(e||event)])) return null;

Now during tree's init , the next code can be used

tree.attachEvent("onBeforeDrag",function(id,ev){
       this.enableMercyDrag(ev.ctrlKey)
       return true;
})

as result - if drag operation was started with ctrl-key pressed, tree will work in drag-as-copy mode.