SFML community forums

Help => Window => Topic started by: barnack on August 07, 2018, 06:19:27 pm

Title: get events when window is not in focus
Post by: barnack on August 07, 2018, 06:19:27 pm
Is it possible to get events with waitEvent (or even pollEvent) without the window being in focus? Some (although not many) programs do that. For example you can play with PCSX2 while the window is not in focus.

An example would be making an on screen keyboard which highlights buttons pressed without being on focus, for making usage videos of another program.
Title: Re: get events when window is not in focus
Post by: Hapax on August 07, 2018, 07:35:59 pm
You can continue to get the real-time state of input devices without using window events; maybe that's what you're hoping to do?

For the example given, you can simply use something like
if (sf::Keyboard::isKeypressed(sf::Keyboard::A))
    aIsPressed = true;
to see if the A key is pressed, for example.