Paper.js: why does tool.onMouseDown not trigger?
Asked Answered
M

1

6

I'm creating a web application that uses Paper.js to manipulate vectors that are imported through SVG. Up until recently, everything worked. Then, all of a sudden, the onMouseDown event stopped getting triggered, even though onKeyDown and onMouseMove trigger just fine.

I create an instance of a Tool object like this:

paper.setup("canvas");
var tool = new paper.Tool();
tool.activate();

Then I bind events later in the code like this:

tool.onMouseDown = function (event) {
  console.log("Mouse down triggered!");
}
tool.onMouseMove = function (event) {
  console.log("Mouse move triggered!");
};

For some reason the latter does trigger, but the former does not. Other events like onKeyDown and onKeyUp trigger as well, but onMouseDown and onMouseDrag don't do anything. Does anyone have an idea what's causing this? I'm also using jQuery and jQueryUI, maybe that causes some kind of interference?

Mcghee answered 28/9, 2015 at 14:28 Comment(0)
B
5

I had the same effect. It was caused by an overlaying html element eating up the click events. Add

style="pointer-events:none;"

to the elements html definition and then both events should trigger you paper.js object.

The full line reads:

<div id="colorizerOptions" style="pointer-events:none;"></div>
Balderas answered 20/1, 2016 at 16:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.