0

Using KineticJS, I created a Circle: using the following line:

var circle = new Kinetic.Circle({...});

Then, I started listening to the 'click' event this way:

circle.on("click", function(evt) {
  // Hope to get the mouse button, x and y here...
});

Using the evt object above, I hope to get the mouse button that was used to click, and the X and Y of the click location. I inspected the evt object, and could not find any of these.

I did get the target node, and the event type from this 'evt' object though.

Am I missing anything? May be another argument to the click handler?

I will post a SSCCE if this information is not enough.

Any response is appreciated!

wavicle
  • 1,284
  • 1
  • 10
  • 12

1 Answers1

1

In the latest KineticJS version (5.1.0), you can get the position by accessing evt.evt.clientX and evt.evt.clientY.

Regarding the detection of which mouse button was clicked, you could take a look at this approach with jquery for cross-browser support

Community
  • 1
  • 1
pgrodrigues
  • 2,083
  • 1
  • 24
  • 28
  • Thanks! I guess evt.evt gives you the native event object. I wonder why KineticJS chose not to make the coordinates and the mouse button directly available, rather than leaving it to us to figure out. – wavicle Jun 24 '14 at 04:09