1

如何检测对画布边框的点击,而不是其内容?

我知道我可以验证范围 event.mouseX (Y),但我的画布有圆角,在某些情况下看起来是一个圆圈,有没有办法知道画布的边框是否在指针下方?

我有:

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

3 回答 3

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.

于 2011-08-29T18:47:47.773 回答
0

我对这个特定主题了解不多,但是您是否考虑过设置某种挑选机制?

您可以拥有一个从不显示但将所有内容绘制到的图形缓冲区。您想区分的每一件事都用不同的颜色绘制。这样,对于任何鼠标事件,您都可以确定鼠标在什么地方,包括将以自己的颜色绘制的边框,并将适当的事件传递给该对象。

如果您找不到任何其他方法,可能仅作为最后的手段有用。

于 2011-08-29T19:12:30.813 回答
0

让一张比前面的画布大 10 像素的画布与您的实际内容一起怎么样。然后,后面的画布注册点击,而前面的画布则没有您的实际内容。

于 2011-08-31T03:14:23.553 回答