开发者

How to easily detect click inside of rectangle/image?

开发者 https://www.devze.com 2023-02-17 04:14 出处:网络
When I draw a开发者_运维问答n image, I know I could find out whether the user clicks on it by comparing X,Y of mouse with position and size of that image.

When I draw a开发者_运维问答n image, I know I could find out whether the user clicks on it by comparing X,Y of mouse with position and size of that image. However is there a quicker way? I know for two rectangles there is an intersect methods. Thanks


Ultimately, the same thing has to happen. The point coordinates need to be tested against the rectangle coordinates. But if you already have Rectangle r and Point p, you can do if (r.Contains(p)).


Not sure if this is possible (as I'm a bit unclear on what you are trying to accomplish), but maybe you can put a button behind the area you want to make clickable and assign an image to that button.

0

精彩评论

暂无评论...
验证码 换一张
取 消