Hi Guru,
I’m cannot manage to resolve a strange problem: I’ve build from HTML drag example an application that tries to drag a node from HTML into a group but when I use the FindAtPart method to get group key it return ALWAYS a null object…But when the node is already in the canvas and I move it to group the event mousedrop of the group fires and the node is associated… I wonder if the drop area of the group node is too smaller to be hit by the drop event (!)
Here’s the code for the drop event (it’s quite the same of the example):
div.addEventListener("drop", function(event) {
// prevent default action
// (open as link for some elements in some browsers)
event.preventDefault();
// Dragging onto a Diagram
if (this === myDiagram.div) {
var can = event.target;
var pixelratio = window.PIXELRATIO;
// if the target is not the canvas, we may have trouble, so just quit:
if (!(can instanceof HTMLCanvasElement)) return;
var bbox = can.getBoundingClientRect();
var bbw = bbox.width;
if (bbw === 0) bbw = 0.001;
var bbh = bbox.height;
if (bbh === 0) bbh = 0.001;
var mx = event.clientX - bbox.left * ((can.width / pixelratio) / bbw) - dragged.offsetX;
var my = event.clientY - bbox.top * ((can.height / pixelratio) / bbh) - dragged.offsetY;
var point = myDiagram.transformViewToDoc(new go.Point(mx, my));
myDiagram.startTransaction('new node');
var pnt=point.x.toFixed(2)+" "+point.y.toFixed(2)
var idP= event.dataTransfer.getData('text/plain');
var dsP= event.dataTransfer.getData('text/html');
var tyP= event.dataTransfer.getData('text/text/uri-list');
//event.preventDefault();
var containerkey = undefined;
var node = myDiagram.findPartAt(point, false);
if (node instanceof go.Group) {
containerkey = node.data.key;
} else if (node instanceof go.Node) {
var group = node.containingGroup;
if (group !== null) containerkey = group.data.key;
}
[...] some code to add node
Here’s the dragged group:
pls help me…
Regards