SFML community forums

Help => Window => Topic started by: sludge on August 22, 2010, 02:09:18 am

Title: mouse input not always registering
Post by: sludge on August 22, 2010, 02:09:18 am
The title says everything.

In my gameloop, the following variable is checked for a left mouse clicked every iteration.

const sf::Input& input = editorWindow.GetInput();

I noticed that sometimes the mouse does not seem to respond as anticipated.  After adding a simple cout statement after

if(input.IsMouseButtonDown(sf::Mouse::Left))

I learned that the condition is not returning true after every time I press the left mouse button.  I know that the input class is used to gather real-time input.  Are some of the mouse clicks not being registered simply because of a lag in between calls to GetInput()?

I imagine that things will function as expected if I check for a mouse event instead?  Is this the case?
Title: mouse input not always registering
Post by: Hiura on August 22, 2010, 09:02:27 am
if there is a «lag» it's with cout.

sf::Input is updated with sf::Event. So using sf::Event will not change anything here.
Title: mouse input not always registering
Post by: Recruit0 on August 23, 2010, 02:06:57 am
It depends on where you're calling it. If it's not in the event handler code, then it could miss it.
Title: mouse input not always registering
Post by: sludge on August 25, 2010, 06:43:30 am
Ah ha.  I figured it out.  After you mentioned that input and events are essentially the same thing, it all clicked.