cancel()
Cancel the click event.
Description
Cancel the click event. This could be used if you, while a mouse button is pressed down, want to abort so that the click event is not triggered when the button is released, even though the start and end position is within the object.
Return Value
Mouse. Returns the mouse module itself.
Examples
Example 1
We create a core instance and a rectangle and add it to the canvas. Then we bind handlers to both the click event and the mousedown event. In the handlers we set a new fill for the rectangle. In the mousedown handler we also call the cancel() method, which stops the click handler from being triggered, thus only running the mousedown handler when clicked.
View Example
Code
var canvas = oCanvas.create({
canvas: "#canvas",
background: "#ccc"
});
var rectangle = canvas.display.rectangle({
x: 77,
y: 74,
width: 200,
height: 100,
fill: "#000"
});
canvas.addChild(rectangle);
rectangle.bind("click", function () {
rectangle.fill = "#f00";
canvas.redraw();
}).bind("mousedown", function () {
canvas.mouse.cancel();
rectangle.fill = "#00f";
canvas.redraw();
});
Output