weird behavior of window children

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
chronos1981
Posts: 8
Joined: Wed Mar 19, 2008 12:03 pm

weird behavior of window children

Post by chronos1981 »

I have added a window to my program and added a few textures as children to the window. The textures in the window can be scrolled up or down by left clicking within the window and dragging the mouse up or down. I want to right click on one of the textures and change the position of it to signify that it is selected, when I attempted that, nothing happened. So I debugged a little, if I right clicked and the cursor was not inside the window or texture it worked, but just as soon as I moused over the window the textures would realign to the left. My question is, is there something that auto aligns children to their parent, I know you can use setAlignment on the textures but I have not done that. Is there a default alignment that is done at creation of the child texture?

If I need to post some code I will, the program is 500 or so lines, and I'm not sure of what parts to post.

Here is a bit of the code before I debugged.

Code: Select all

// gui scroll
			
			if( receiver.IsLMBDown() == true && texWin->isPointInside(device->getCursorControl()->getPosition()) == true)
			{
				int iniCursorPos = device->getCursorControl()->getPosition().Y;//1, 3
				while(device->getCursorControl()->getPosition().Y == iniCursorPos)
				{
					//need to calculate time from mouse down to mouse up and get velocity 
				}
				int CurCursorPos = device->getCursorControl()->getPosition().Y;//3, 1
				for(int w = 2; w < numFile; w++)
				{

					GUIM[w]->setRelativePosition(vector2d<s32>(GUIM[w]->getRelativePosition().UpperLeftCorner.X,GUIM[w]->getRelativePosition().UpperLeftCorner.Y-(iniCursorPos - CurCursorPos)));
					GUIM[w]->updateAbsolutePosition();
				}
				speed = iniCursorPos - device->getCursorControl()->getPosition().Y ; // distance
			}
			
// gui select
			if( receiver.IsRMBDown() == true && texWin->isPointInside(device->getCursorControl()->getPosition()) == true)
			{
				for(int sw = 2; sw < numFile; sw++)
				{
					//if(GUIM[sw]->isPointInside(device->getCursorControl()->getPosition()) == true)
					//{
						GUIM[sw]->setRelativePosition(vector2d<s32>
									(50,
									GUIM[sw]->getRelativePosition().UpperLeftCorner.Y));
						GUIM[sw]->updateAbsolutePosition();
					//}
				}
			}
Well I found my error I feel dumb now ha.

Code: Select all


if( receiver.IsLMBDown() == false && receiver.IsRMBDown() == false && texWin->isPointInside(device->getCursorControl()->getPosition()) == true)
			{
					for(int w = 2; w < numFile; w++)
					{
						
						GUIM[w]->setRelativePosition(vector2d<s32>0,GUIM[w]->getRelativePosition().UpperLeftCorner.Y-(speed)));// this line was setting the textures back to 0 on the X axis arghh
						//																			0 - (3-1) = -2
						//																			0 - (1-3) = +2
						GUIM[w]->updateAbsolutePosition();
						
					}
					speed = speed / 1.1;
				
			}
Post Reply