1

How I can detect a click on the border of a canvas, not its contents?.

I am aware that I can validate ranges event.mouseX (Y), but my canvas has rounded corners and in some cases appears to be a circle, is there any way of knowing if the border of the canvas is under the pointer?

I have:

Canvas.setStyle ("borderColor", 0xFF0000);
Canvas.setStyle ("borderStyle", "solid");
Canvas.setStyle ("BorderThickness", 10);

3 Answers3

0

Judging by a 10px thickness what is the real problem if the user clicks on the border or the canvas? Do you have event listeners that are being invoked when the canvas is clicked on? If so, maybe you should refine those listeners to tune into the events dispatched from the contents of the canvas rather than the canvas itself.

Mark Lapasa
  • 1,644
  • 4
  • 19
  • 37
  • Thanks Mark, But this event is a requirement of the customer, because the canvas has no content, but rather serves as a mask to define an area on a chart type universe, and we need only the edge, which is quite wide, has the functionality . the listener, already validated when the edge is like a rectangle, the problem comes when the edge is curved and resembles a sphere – Omar Alejandro Aug 29 '11 at 19:06
  • If it defines an area, do you really need to detect clicks on the border (as opposed to the entire area, border and inside the border)? – Lars Blåsjö Aug 30 '11 at 12:38
0

I don't know much about this particular topic, but have you thought about setting up some sort of picking mechanism?

You can have a graphics buffer that you never display, but draw everything to. Each thing you'd like to distinguish you draw in a different color. That way you can, for any mouse event, figure out what the mouse was over, including the border which would be drawn in its own color, and pass the appropriate event to that object.

Probably only useful as a last resort, if you can't find any other way of doing it.

Dogmatixed
  • 794
  • 1
  • 11
  • 33
0

How about having one canvas that is 10px larger than the one in front of it with your actual content. Then that back canvas register for a click and the front one with your actual content not.

Mike007
  • 530
  • 1
  • 5
  • 10