Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking mouse events in Artist #163

Open
alexandremeunier opened this issue Jul 28, 2014 · 0 comments
Open

Tracking mouse events in Artist #163

alexandremeunier opened this issue Jul 28, 2014 · 0 comments

Comments

@alexandremeunier
Copy link
Contributor

Following #159, we now have a list of all shapes currently drawn on canvas. We need to be able to pass mouse events callbacks as arguments when drawing the shapes, in a way similar to that:

this.artist.rect(10, 10, 10, 20, {
  fillStyle: 'red',
  click: function(event) { console.log('click'); }
});

Definining mouse event callback will cause the artist to automatically track the shape, and store a reference to the callbacks.

Then, we need to capture the click, mouseenter, mouseleave events on the $canvas object (in the Artist), and check whether the mouse was in one of the shapes we are tracking. For all the shapes in which the mouse click/hovering happened, we need to trigger the callback defined before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant