Get 2D x,y cursor position on mouse click

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Tonyx
Posts: 14
Joined: Fri Mar 11, 2005 5:13 pm

Get 2D x,y cursor position on mouse click

Post by Tonyx »

Is possible Get 2D x,y cursor position on mouse click if i click on a irr::gui::IGUIEnvironment::addImage ?

Tnx
Tony.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
Post Reply