Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Mouse clicks/Key states when window not active  (Read 1123 times)

0 Members and 1 Guest are viewing this topic.

xinux

  • Newbie
  • *
  • Posts: 13
    • View Profile
Mouse clicks/Key states when window not active
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Mouse clicks/Key states when window not active
« Reply #1 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.
Laurent Gomila - SFML developer

xinux

  • Newbie
  • *
  • Posts: 13
    • View Profile
Mouse clicks/Key states when window not active
« Reply #2 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!

 

anything