SFML community forums

Help => Window => Topic started by: Aether92 on September 12, 2013, 03:29:53 am

Title: Cannot move 2nd window when created
Post by: Aether92 on September 12, 2013, 03:29:53 am
I'm having a problem where I open up my game, the screen opens and when I hit exit a 2nd window opens asking if you're sure.
When this window spawns I cannot click and drag the box or click close when the box spawns on top of the 1st window.

Meaning if I spawn the 2nd window, click back to the 1st then drag it out of the way I can now click and move the window.

Also I've assigned a keypress so if you hit Return while this 2nd window is open it will close everything, this does work perfectly fine, the only problem is clicking and dragging the actual box.

The way I do it is...

                while (Game.pollEvent(Event))
                {
                        if ((Event.type == sf::Event::Closed) || (sf::Keyboard::isKeyPressed(sf::Keyboard::LAlt) && sf::Keyboard::isKeyPressed( sf::Keyboard::F4)) || (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)))
                        {
                                CreateExit(sf::VideoMode(300,100), sf::String("Exit?"));
                        }
                }

                while(ExitScreen.isOpen())
                {
                        while (ExitScreen.pollEvent(Event))
                        {
                                if ((Event.type == sf::Event::Closed))
                                {
                                        ExitScreen.close();
                                }

                                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Return))
                                {
                                        Game.close();
                                        ExitScreen.close();
                                }
                        }
                }
Title: Re: Cannot move 2nd window when created
Post by: zsbzsb on September 12, 2013, 05:11:00 am
I'm not sure exactly what your problem is (it sounds like something with events), but you really should not use a second window as a dialog for the user. SFML wasn't designed to make modal popups for the user. You should instead just create some sort of exit confirmation inside your main window and go from there (how many games do you see that create a separate popup window for confirmation?).