i have installed sfml2.3.2 and tried using !window.hasFocus().
but its still didnt count when the window is lost focus.
and heres the main:
int main(){
kps count;
RenderWindow kps_wind(VideoMode(275,75),"KeyPerSecond");
while(kps_wind.isOpen()){
kps_wind.setKeyRepeatEnabled(false);
Event e;
while(kps_wind.pollEvent(e)){
if(e.type == Event::Closed)
kps_wind.close();
if ((e.type == Event::KeyPressed && e.key.code == Keyboard::Z) && !kps_wind.hasFocus()){
count.addkey1();
}else if((e.type == Event::KeyPressed && e.key.code == Keyboard::Z) && kps_wind.hasFocus()){
count.addkey1();
}
}
//////DRAW//////
Font font;
if (!font.loadFromFile("Arial.ttf")){}
//Text text(count.getkey1(), font, 24);
Text text;
text.setString(count.getkey1());
text.setFont(font);
text.setCharacterSize(24);
text.setColor(Color::Red);
text.setPosition(0,0);
kps_wind.clear(Color::Black);
kps_wind.draw(text);
kps_wind.display();
}
return 0;
}
please help