Page 1 of 1

Get 2D x,y cursor position on mouse click

Posted: Wed Apr 18, 2007 9:03 am
by Tonyx
Is possible Get 2D x,y cursor position on mouse click if i click on a irr::gui::IGUIEnvironment::addImage ?

Tnx
Tony.

Posted: Wed Apr 18, 2007 3:56 pm
by vitek
Yes. In your event receiver, get the mouse position when the mouse is pressed or released. Get the absolute rectangle that the image is using, and ask the rectangle if the mouse position is inisde the rectangle. If you need the mouse position on the coordinate system of the image, you could do a little subtraction to get that.

Since you are handling clicks on a gui element, you might want to consider making the element a button. The button generates a click message when it is clicked. Then all you'd need to do is get the mouse position from the cursor control.

Travis