1
Window / Re: sf::Event::KeyReleased event bug in SFML 2.0 ?
« on: May 19, 2013, 03:47:28 pm »
Seeing your code I understand why my code is bloated .
Okay, I used your code:
and this is the output:
as it can be seen at 5, 6 and 13 the key release event didn't triggered
Thank you for your reply and help.
Okay, I used your code:
#include <SFML/Window.hpp>
#include <iostream>
int main()
{
sf::Window window(sf::VideoMode(640, 480), "SFML Test");
window.setKeyRepeatEnabled(false);
sf::Clock clock;
int i = 0;
for (;;)
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
return 0;
case sf::Event::KeyPressed:
if (event.key.code == sf::Keyboard::F)
std::cout << ++i << "\tPressed \t"
<< clock.getElapsedTime().asMilliseconds() << std::endl;
break;
case sf::Event::KeyReleased:
if (event.key.code == sf::Keyboard::F)
std::cout << "\tReleased\t"
<< clock.getElapsedTime().asMilliseconds() << std::endl;
break;
}
}
window.display();
}
}
#include <iostream>
int main()
{
sf::Window window(sf::VideoMode(640, 480), "SFML Test");
window.setKeyRepeatEnabled(false);
sf::Clock clock;
int i = 0;
for (;;)
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
return 0;
case sf::Event::KeyPressed:
if (event.key.code == sf::Keyboard::F)
std::cout << ++i << "\tPressed \t"
<< clock.getElapsedTime().asMilliseconds() << std::endl;
break;
case sf::Event::KeyReleased:
if (event.key.code == sf::Keyboard::F)
std::cout << "\tReleased\t"
<< clock.getElapsedTime().asMilliseconds() << std::endl;
break;
}
}
window.display();
}
}
and this is the output:
as it can be seen at 5, 6 and 13 the key release event didn't triggered
1 Pressed 2041
Released 2535
2 Pressed 2942
Released 3553
3 Pressed 3907
Released 4417
4 Pressed 4795
Released 5309
5 Pressed 5704
6 Pressed 7007
7 Pressed 8262
Released 8839
8 Pressed 9365
Released 9892
9 Pressed 10364
Released 10963
10 Pressed 11402
Released 12018
11 Pressed 12421
Released 13115
12 Pressed 13542
Released 14149
13 Pressed 14618
14 Pressed 16177
Released 16734
Released 2535
2 Pressed 2942
Released 3553
3 Pressed 3907
Released 4417
4 Pressed 4795
Released 5309
5 Pressed 5704
6 Pressed 7007
7 Pressed 8262
Released 8839
8 Pressed 9365
Released 9892
9 Pressed 10364
Released 10963
10 Pressed 11402
Released 12018
11 Pressed 12421
Released 13115
12 Pressed 13542
Released 14149
13 Pressed 14618
14 Pressed 16177
Released 16734
Thank you for your reply and help.