I want to call my custom callback function every time, when user starts dragging figures. I tried to do it like so:
figure.onDragStart = function (x, y, shiftKey, ctrlKey) {
myfunc();
};
But the problem is, every time when my function is called, figure is positioned to 0,0 coordinate. I'm not sure what is wrong with that and how can I fix it.
Instead of redefining the
onDragStartmethod, you can handle thedragstartevent:According to the draw2d documentation, that event is triggered by
onDragStart. Theuiparameter containsx,y,shiftKeyandctrlKey.You can see the code in action in this jsfiddle. A message is displayed in the console when you start dragging a rectangle. The green rectangle uses the
dragstartevent and responds correctly. The red one redefines theonDragStartmethod, with the problem mentioned in your question.