SFML community forums

Help => Window => Topic started by: xinux on August 15, 2011, 11:05:27 pm

Title: Mouse clicks/Key states when window not active
Post by: xinux on August 15, 2011, 11:05:27 pm
I'm updating my current project to use the latest sfml version, and I have stumbled upon something I don't know how to solve.

When i de-select my game window and f.e. click the windows start button, my character fires his gun, and if I write something in notepad my character jumps around.

Is there any simple fix, like a bool to set to false to not capture things outside of my application?

Also I want to suggest that 'not capturing things from outside of the application' should be true by default.
Title: Mouse clicks/Key states when window not active
Post by: Laurent on August 15, 2011, 11:10:11 pm
Quote
Is there any simple fix, like a bool to set to false to not capture things outside of my application?

Catch focus events, and only apply things when your window is in focus.

Quote
Also I want to suggest that 'not capturing things from outside of the application' should be true by default.

It's not that simple. The new Keyboard/Mouse/Joystick classes directly request the devices states, they don't care about a window having the focus or not.

But I admit that this is a problem, and I'll provide a more convenient way to handle it.
Title: Mouse clicks/Key states when window not active
Post by: xinux on August 15, 2011, 11:19:03 pm
Quote from: "Laurent"
Quote
Is there any simple fix, like a bool to set to false to not capture things outside of my application?

Catch focus events, and only apply things when your window is in focus.

Quote
Also I want to suggest that 'not capturing things from outside of the application' should be true by default.

It's not that simple. The new Keyboard/Mouse/Joystick classes directly request the devices states, they don't care about a window having the focus or not.

But I admit that this is a problem, and I'll provide a more convenient way to handle it.


Ah, didn't know there were events for focus.
I'll use them to set a boolean and check it before i do anything with the events.
Looking forward to future updates!