Hi all!)
dojo.dnd.Source component allows user by default to press Ctrl-key while dragging item to create a copy of this item. This is very nice feature, but I want to disable it for one container. I just want user to have the ability to reorder items inside the container, but not to copy items.
I read dojoBook, api refs, docs, but failed to find how to disable item copying. Can somebody help me with it?
Thanks.
ps: btw, dojo is really perfect toolkit, like it very much. Thanks a lot!

custom source
Hi!
I have had the same problem and found this solution:
dojo.declare("rs.dnd.noCopySource", dojo.dnd.Source, {
markupFactory: function(params, node){
params._skipStartup = true;
return new rs.dnd.noCopySource(node, params);
},
copyState: function(){
return false;
},
onDndDrop: function(source, nodes, copy){
dojo.dnd.Source.prototype.onDndDrop.call(this, source, nodes, copy);
}
});
Declare your own source class and inherit from dojo.dnd.Source. copyState() now returns false and on drop you invoke the original function.
Wow... Thanks a lot, I'll
Wow...
Thanks a lot, I'll try it!
If there is an alternate solution, I would also like to hear it.
found nothing else
This solution seems to be the way to go. This solution is posted multible times in this forums.
There is a property which allows only copying but no "onlyMove" :( Would be nice if it gets implemented in future releases.
Ok. Thanks again. Agree
Ok. Thanks again.
Agree about waiting for future releases. It is rather strange to create copyOnly flag, but forget about moveOnly ;)
Zebi, your script worked
Zebi, your script worked fine in Dojo1.1.1, thanks a lot! But it seems to be broken in Dojo1.2. It cannot move items at all. DnD creates avatar and placemarks for suggested position, but no real moving occures on mouseUp.
Can somebody help? Question is still to create DnD container that is able to rearrange items, but cannot copy it.
Thanks again.
Hmm, I spend some time
Hmm, I spend some time looking at dojo.dnd.Source code and lucky it looks like there is only one update necessary. Here is the code, that at least works as expected:
//Declaring new class
dojo.declare("noCopySource", dojo.dnd.Source, {
markupFactory: function(params, node){
params._skipStartup = true;
return new noCopySource(node, params);
},
copyState: function(){
return false;
},
onDndDrop: function(source, nodes, copy, target){ // forth parameter added here
dojo.dnd.Source.prototype.onDndDrop.call(this, source, nodes, copy, target); // and here
}
});
//Using it
var containerWj = new noCopySource('ID');
containerWj.insertNodes(.....);
Dojo sources looks very complicated to me, I'm not experienced JS-programmer, so i'm not sure this corrections is enough to be completely correct. But at least, it works.
If someone wants something to say on this topic, I would like to hear it.
BTW: I will be very happy, when dojo.dnd.Source will have "MoveOnly" flag out-of-the-box :)
Anyway, Dojo is fine toolkit, thanks for your work!
good to know
I have not updated to 1.2 so this is good to know. Thanks for posting the solution here :)