I'll try to give you a really simplify version of the issue I am encountering. This is just to show you where is my problem :
// windowMain and windowAux are two sf::renderwindow created
while (windowMain.isOpen())
{
sf::Event event;
while (windowMain.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed: // closing using the cross button of the window
windowMain.close(); // close the main window and gets out of this loop
break;
case sf::Event::MouseButtonPressed: // clicking
createWindowAux(windowAux); // pops windowAux
windowAux.display();
break;
default:
break;
}
}
while (windowAux.pollEvent(event)) // loop on editing/reading attributes
{
switch (event.type)
{
case sf::Event::Closed:
windowAux.clear(COLOR_BACKGROUND_WINDOW);
windowAux.close();
break;
case sf::Event::LostFocus:
cout << "LOSTFOCUS" << endl;
break;
case sf::Event::GainedFocus :
windowAux.clear(COLOR_BACKGROUND_WINDOW);
// add objects here
windowAux.display();
cout << "GAINFOCUS" << endl;
break;
case sf::Event::Resized :
cout << "RESIZED" << endl;
break;
default:
break;
}
}
}
I just re-explain the problem I got (not so easy to explain sorry). By clicking on the mainWindow while the windowAux is opened, i do not get the event LOSTFOCUS in window2 (maybe I need to make 2 distincts event but I do not think so - events should be all equal at same time I suppose).
However, clicking on an other window - (not from SFML) as MicrosoftVisualStudios (for instance) - will give me the lostfocus event.
Also, this is the code for the creation of the window :
void createWindowForAttributes(sf::RenderWindow& window)
{
if (!window.isOpen()) // if not already opened, creation of the window
{
window.create(sf::VideoMode(WIDTH_WINDOW_ATTRIBUTE,
HEIGHT_WINDOW_ATTRIBUTE),
"Editing", sf::Style::Titlebar | sf::Style::Close);
}
window.setTitle("Editing");
window.setSize(sf::Vector2u(WIDTH_WINDOW_ATTRIBUTE,
HEIGHT_WINDOW_ATTRIBUTE));
window.clear(COLOR_BACKGROUND_WINDOW);
}
Thanks,
Tell me if you need anything else for the explanation,
Gabriel