Checking whether a position2d<s32> is within an IGUIIm

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
AndyCR
Posts: 110
Joined: Tue Nov 08, 2005 2:51 pm
Location: Colorado, USA
Contact:

Checking whether a position2d<s32> is within an IGUIIm

Post by AndyCR »

I saw some function within Irrlicht yesterday that checked if a given position2d was within either a rect or a IGUIImage... today I can't for the life of me find it... does anyone know where it is? i could make it myself, but i'd rather not clutter up my code with either a long if statement or an unneeded utility function.

Thanks in advance.
ImNoHelp

Post by ImNoHelp »

well im not sure if ive seen that code but the logic isnt that hard, if the position.X is greater than the rect.Left but less than the Rect.Right, and the position.Y is greater than the rect.Top but less than the Rect.Bottom... then return true.. else.. return false... simple kinda function.
Conquistador
Posts: 340
Joined: Wed Sep 28, 2005 4:38 pm
Location: Canada, Eh!

Post by Conquistador »

If you want to find which GUI element your mouse is over, use getElementFromPoint(), http://irrlicht.sourceforge.net/docu/cl ... nt.html#a6

It'll work for anything derrived from IGUIElement.
Royal Hamilton Light Infantry - http://www.rhli.ca
Paris/Port Dover Pipes'n Drums - http://www.parisdover.ca
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Code: Select all

  rect.isPointInside(point); // will return true if point is in rect
Guest

Post by Guest »

@ImNoHelp: Thanks, I did that earlier, it just looked really ugly and I didn't want to resort to it unless I had to.

@Conquistador, vitek: Thanks, either should do the job nicely! :D

Everyone, thanks again for all your help!
Post Reply