Heyy rrybody
I have this function that when given the x and y of the mouse will select a window but the problem is sometime when i create a few of the same windows then try to select one of the windows it selects the wrong window and doesnt move anything
int WindowManager::GetWindow(int i_X, int i_Y) //Returns -2 if a window is erased, ID of windows selected or -1 if no window is selected
{
vector<Window>::iterator it;
int t_Window = -1;
int temp;
for (it = m_Windows.begin(); it != m_Windows.end(); ++it)
{
if (i_X >= it->GetX() && i_X <= (it->GetX()+it->GetWidth()) && i_Y >= it->GetY() && i_Y <= (it->GetY()+it->GetHeight()) )
{
cout << "Iterator ID " << it->GetID() << endl;
cout << it->GetX() << " " << it->GetY() << endl;
temp = CheckAndSelectItems(it, i_X, i_Y); //returns -2 on erase, 1 when being moved, 0 when buttons pressed
if (temp != 1)
return temp;
return (t_Window = it->GetID());
}
}
return t_Window;
}
Here i was trying to select window 2 but it keep printing out window 1's id instead of 2's, and wouldnt do anything http://i.imgur.com/Eh2mq.jpg
Iterator ID 1
389 29
(gdb) p i_X <--- Mouse X
$1 = 475