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

Author Topic: Some keys not registering to close window  (Read 1927 times)

0 Members and 1 Guest are viewing this topic.

big_totoro

  • Guest
Some keys not registering to close window
« on: November 06, 2012, 10:38:31 pm »
Hello, I'm a complete SFML rookie so I've been reading through the tutorials on the site.
I've got to the one that talks about using events to close the window and I've copied the code exactly.
This is the bit that handles the events:

        sf::Event Event;
        while (App.GetEvent(Event));
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();

            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();
        }

The program runs fine and closes properly when I press the X but pressing escape does nothing.
I tried F5 because that was a key given in another example and it worked! Also, none of the letter keys work but the arrow keys do. It seems strange that some work and some don't.

I'm probably missing something really obvious but if anyone can help me solve this it would be much appreciated.

Thanks!
« Last Edit: November 06, 2012, 10:57:27 pm by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Some keys not registering to close window
« Reply #1 on: November 06, 2012, 10:46:17 pm »
What's your OS?

Can you show the full code?
Laurent Gomila - SFML developer

big_totoro

  • Guest
Re: Some keys not registering to close window
« Reply #2 on: November 06, 2012, 10:48:46 pm »
Thanks for the fast reply!
I'm using Code::Blocks with MinGW 4.4 on Windows 7 home premium.
Here's the code:

// Window

#include <sfml/System.hpp>
#include <sfml/Window.hpp>
#include <iostream>

int main()
{
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML window");

    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event));
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();

            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();
        }
        App.Display();
    }
    return EXIT_SUCCESS;
}
 

« Last Edit: November 06, 2012, 10:57:41 pm by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Some keys not registering to close window
« Reply #3 on: November 06, 2012, 11:00:09 pm »
Strange. What is your keyboard layout? Standard US QWERTY?
Laurent Gomila - SFML developer

big_totoro

  • Guest
Re: Some keys not registering to close window
« Reply #4 on: November 06, 2012, 11:04:05 pm »
No, UK. It's a Samsung laptop, I dunno if that changes anything.
I've been testing some others and it's still seems its only the F keys and arrow keys that work. Return, Space, Backspace etc. don't and neither do any of the letter keys. Not sure how to do numbers though.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Some keys not registering to close window
« Reply #5 on: November 06, 2012, 11:07:11 pm »
I have no idea, sorry :-\

Just to be sure, can you test SFML 2.0? (1.6 is already outdated anyway)
Laurent Gomila - SFML developer

big_totoro

  • Guest
Re: Some keys not registering to close window
« Reply #6 on: November 07, 2012, 06:05:55 pm »
Downloaded SFML 2.0 and made a new version and it works fine. I'm having a bit of trouble with linking to static libraries though so maybe I'll start a new topic. Anyway, problem solved, thanks!

(Sorry, emailed you because I thought you had closed the topic but it turns out I was auto logged out lol! Just posted this to let others know it's been resolved.)

 

anything