R
R
Ruslan Serg2019-11-05 17:38:48
JavaScript
Ruslan Serg, 2019-11-05 17:38:48

How to bind event handlers to elements in canvas?

There are several elements in the canvas. No matter what, but let's say circles. How, for example, to bind an event handler to one of these circles so that it and specifically it, and not the neighboring one, turns red from black?
Please leave a link to some tutorial or article where this interaction is described.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2019-11-05
@RuslanSerg

So?
You need to hang the handler on the canvas itself. And inside it, get the mouse coordinates and calculate the coordinates of the element where the click was.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question