cancel()

Cancel the tap event.

Syntax cancel()

Return Type Touch

Description

Cancel the tap event. This could be used if you, while a finger is pressed down, want to abort so that the tap event is not triggered when the finger is released, even though the start and end position is within the object.

Return Value

Touch. Returns the touch 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 tap event and the touchstart event. In the handlers we set a new fill for the rectangle. In the touchstart handler we also call the cancel() method, which stops the tap handler from being triggered, thus only running the touchstart handler when tapped.

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("tap", function () {
	rectangle.fill = "#f00";
	canvas.redraw();
}).bind("touchstart", function () {
	canvas.touch.cancel();
	rectangle.fill = "#00f";
	canvas.redraw();
});
Output