SFML community forums
Help => Window => Topic started by: model76 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 forif( event.Type == sf::Event::KeyReleased && event.Key.Code == sf::Key::LAlt )
in the event loop. ;)
Thanks!
-
On what OS, and with which version of SFML?
-
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.
-
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:#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?
-
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.
-
By the way, this has already been discussed:
http://www.sfml-dev.org/forum/viewtopic.php?t=2910
-
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 ;)