[fixed] getElementFromPoint(), what do you think ?

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
jolindien
Posts: 16
Joined: Sun Jul 16, 2006 3:00 pm
Location: Lyon (France)

[fixed] getElementFromPoint(), what do you think ?

Post by jolindien »

Here is something looking like a side effect bug :

shouldnt this function be :

Code: Select all

IGUIElement* getElementFromPoint(const core::position2d<s32>& point)
	{
		IGUIElement* target = 0;

		// we have to search from back to front.

		core::list<IGUIElement*>::Iterator it = Children.getLast();

		if (IsVisible)
			while(it != Children.end())
			{
				target = (*it)->getElementFromPoint(point);
				if (target)
					return target;

				--it;
			}

		if (AbsoluteClippingRect.isPointInside(point) && IsVisible)
			target = this;
		
		return target;
	}
-> if (AbsoluteClippingRect.isPointInside(point) && IsVisible)

instead of

Code: Select all

IGUIElement* getElementFromPoint(const core::position2d<s32>& point)
	{
		IGUIElement* target = 0;

		// we have to search from back to front.

		core::list<IGUIElement*>::Iterator it = Children.getLast();

		if (IsVisible)

			while(it != Children.end())

			{
				target = (*it)->getElementFromPoint(point);
				if (target)
					return target;

				--it;
			}

		if (AbsoluteRect.isPointInside(point) && IsVisible)
			target = this;
		
		return target;
	}
-> if (AbsoluteRect.isPointInside(point) && IsVisible)

The reason why i am stating this is that i'm using the user GUI control CGUITextBox in a tabcontrol in a window, with the CGUITextBox using 70% of the height of the window (i know, pics would be better).

And with this GUI, if you scroll the text within the CGUITextBox what really happens into the code is that a static text is moved upwards/downwards, and then culled for drawing.
So, if you use AbsoluteRect to detect if you are or not on the control, you will get a wrong answer, as the CGUITextBox text is actually "bigger" than the parent window. Then you wont be able to pick the right control (= the window for instance).

After all, getElementFromPoint is used for control "picking", so its a visual thing for users, so you should really try to "pick" what you see = AbsoluteClippingRect.

Dunno if i made it clear, but for me thats an unfortunate bug. What do you think ?
Post Reply