Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: If I allow an SFML program to exit by pressing ESC it will also close with mouse  (Read 6723 times)

0 Members and 2 Guests are viewing this topic.

bonsairobo

  • Newbie
  • *
  • Posts: 11
    • View Profile
This might be something funky with my own computer, but I sent one of my programs to a friend and he had the same problem.

Whenever I poll for an event as written in the code below, my program will close if I circle my mouse cursor around the top or bottom left corners of the window.

The problem is illustrated in this video: http://youtu.be/PD7-y1_H6qo?t=15s

You can try it yourself by downloading my pong game here: http://www.mediafire.com/?6xrvvtbr7qc03jo, but the same problem occurs in any program I make using the method below.

while(tetris.isOpen())
        {
                sf::Event event;
                while(tetris.pollEvent(event))
                {
                        if (event.key.code == sf::Keyboard::Escape)
                                tetris.close();
                }
        }
 
« Last Edit: January 22, 2013, 11:54:54 pm by bonsairobo »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Well you then probably need to read the tutorial again or probably at all...

If you don't check which event happened, but only check for the key code, then the behavior is undefined, since the key code can hold anything...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

bonsairobo

  • Newbie
  • *
  • Posts: 11
    • View Profile
my bad

 

anything