I want to allow the user to draw a rectangle on the canvas with Draw2D library. The canvas location of mouse-down will be top-left and the canvas location of mouse-up should become the bottom right. However, I am unable to catch the mouse-up and mouse-down events on the canvas.
Here is the code I am trying, but there is no output:
var canvas = new draw2d.Canvas("canvas-div");
var policy = new draw2d.policy.canvas.CanvasPolicy();
policy.onClick = function(canvas, mouseX, mouseY) {
console.log("Mouse click:" + mouseX + "," + mouseY);
}
canvas.installEditPolicy(policy);