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

Author Topic: SFML 1.6: Bug with key up event and LALT?  (Read 3323 times)

0 Members and 1 Guest are viewing this topic.

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
SFML 1.6: Bug with key up event and LALT?
« on: November 24, 2010, 04:56:16 am »
Hi Laurent,

I believe I may have fount another bug with the keyboard events:

The first time I press and release LALT, I get no key up event.
The second time, I get 2 key up events: 1 when I press LALT, and 1 when I release it.

It doesn't happen with other keys.

Can you confirm that?

I could write you a minimal example, but it really is as simple as checking for
Code: [Select]
if( event.Type == sf::Event::KeyReleased && event.Key.Code == sf::Key::LAlt )in the event loop. ;)

Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 1.6: Bug with key up event and LALT?
« Reply #1 on: November 24, 2010, 08:16:25 am »
On what OS, and with which version of SFML?
Laurent Gomila - SFML developer

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
SFML 1.6: Bug with key up event and LALT?
« Reply #2 on: November 24, 2010, 11:48:54 am »
Doh! I really meant to say that, but I forgot to write it in the end... Sorry.

I am using SFML 1.6, Visual C++ 2008, and Windows XP 32 bit.

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
SFML 1.6: Bug with key up event and LALT?
« Reply #3 on: November 25, 2010, 01:00:00 am »
Aha! It only happens in windowed mode, so I think I know what the problem might be:

In Windows, Left ALT normally activates the active window's menu, so maybe SFML only receives the event once the (invisible) menu is deactivated.

Left-mouse-clicking the window after Left ALT clicking also produces the key-up event, so that kind of confirms it.

And a final confirmation: Pressing Space after Left ALT actually produces a menu.

Here is a minimal example to play with:
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600), "SFML");

    sf::String sfStr;

    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
            else if( Event.Type == sf::Event::KeyPressed )
                sfStr.SetText( L"Key Pressed" );
            else if( Event.Type == sf::Event::KeyReleased )
                sfStr.SetText( L"Key Released" );
        }

        App.Clear();

        App.Draw( sfStr );

        App.Display();
    }

    return EXIT_SUCCESS;
}

Maybe there is a way you could disable this pesky menu altogether?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 1.6: Bug with key up event and LALT?
« Reply #4 on: November 25, 2010, 08:07:04 am »
Ah you're right, this is the system menu. I don't really want to disable this, since it's a generic OS feature which is supposed to work on every window.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
SFML 1.6: Bug with key up event and LALT?
« Reply #5 on: November 25, 2010, 06:37:09 pm »
By the way, this has already been discussed:
http://www.sfml-dev.org/forum/viewtopic.php?t=2910
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
SFML 1.6: Bug with key up event and LALT?
« Reply #6 on: November 25, 2010, 09:48:32 pm »
Quote from: "Nexus"
By the way, this has already been discussed:
http://www.sfml-dev.org/forum/viewtopic.php?t=2910
So I see. I think I will start compiling a list of SFML gotchas, as they don't seem to make their way into the documentation. Maybe it will be on the wiki one day ;)

 

anything