Blinking ToolTips

Started by MoLAoS, 18 November 2016, 18:55:18

MoLAoS

For some reason tooltips become briefly visible and then blink out and back on repeatedly. Is there a possible reason you can think of easily that this would happen? I'm not executing any code as far as I can tell, and I'm not even moving the mouse.

texus

I can't think of a reason why that would happen without mouse events.

Once visible, it should only be removed again when the handleEvent function is called where this case is true:
Code (cpp) Select
if ((event.type == sf::Event::MouseMoved) || (event.type == sf::Event::MouseButtonPressed)
|| (event.type == sf::Event::MouseButtonReleased) || (event.type == sf::Event::MouseWheelMoved))

MoLAoS

Quote from: texus on 18 November 2016, 19:07:07
I can't think of a reason why that would happen without mouse events.

Once visible, it should only be removed again when the handleEvent function is called where this case is true:
Code (cpp) Select
if ((event.type == sf::Event::MouseMoved) || (event.type == sf::Event::MouseButtonPressed)
|| (event.type == sf::Event::MouseButtonReleased) || (event.type == sf::Event::MouseWheelMoved))


Do you check if I'm on the same parent? Like, even if I move the mouse as long as I'm hovering over the same widget it shouldn't spawn the tool tip again. The timeToDisplay thing could cause an interaction that way, though unless I'm crazy I'm not moving anyways.

texus

As soon as you move the mouse the tooltip will vanish (no matter if you stay on the same widget or not).
The tool tip will only be added after timeToDisplay has passed without a single mouse event (on every mouse event the timer is reset).

MoLAoS

#4
Quote from: texus on 18 November 2016, 19:20:48
As soon as you move the mouse the tooltip will vanish (no matter if you stay on the same widget or not).
The tool tip will only be added after timeToDisplay has passed without a single mouse event (on every mouse event the timer is reset).

That's an interesting choice. In any case I tried again and made sure I wasn't moving the mouse or performing any action and its still blinking.

Is it possible if I'm redrawing the gui which seems instant but the tooltip is slow cause of the timeToDisplay?

I resolved the issue in the sense that there's no more blinking, by setting tTD to 0. I still don't know why it blinks or how to fix it.

texus

The timers are updated when drawing the gui. I can't see any case where they would blink. You shouldn't be able to blink faster than timeToDisplay anyway (and that is when moving the mouse which you aren't doing).
So maybe you can try setting the timeToDisplay to a different value (e.g. 2 seconds) and see if it affects the blinking.

Maybe you can also add the following right in front of the handleEvent call to check that you aren't getting events without knowing it:
Code (cpp) Select
std::cout << ((event.type == sf::Event::MouseMoved) || (event.type == sf::Event::MouseButtonPressed)
|| (event.type == sf::Event::MouseButtonReleased) || (event.type == sf::Event::MouseWheelMoved)) << std::endl;

MoLAoS

Quote from: texus on 18 November 2016, 19:32:27
The timers are updated when drawing the gui. I can't see any case where they would blink. You shouldn't be able to blink faster than timeToDisplay anyway (and that is when moving the mouse which you aren't doing).
So maybe you can try setting the timeToDisplay to a different value (e.g. 2 seconds) and see if it affects the blinking.

Maybe you can also add the following right in front of the handleEvent call to check that you aren't getting events without knowing it:
Code (cpp) Select
std::cout << ((event.type == sf::Event::MouseMoved) || (event.type == sf::Event::MouseButtonPressed)
|| (event.type == sf::Event::MouseButtonReleased) || (event.type == sf::Event::MouseWheelMoved)) << std::endl;


It appears that I am indeed getting events without knowing it although they don't seem to affect anything but the toolTips. When I move the mouse the number of events spikes. Otherwise it appears to be a slow tick, actually about the length of time for the blinking. Further fiddling tells me its detecting phantom mouse movements. I took my hand off the mouse but it made no difference.

texus

What I could do is store the last mouse position and only handle the event when the position changed. I think that should fix the problem. Could you check if the mouse position remains the same during these phantom movements?

It will make my code a bit more complex since I will also have to keep track of what the handleEvent function returned during the last mouse event, but it could be an optimization if the mouse generates a lot of mouse events.

MoLAoS

Quote from: texus on 18 November 2016, 19:56:23
What I could do is store the last mouse position and only handle the event when the position changed. I think that should fix the problem. Could you check if the mouse position remains the same during these phantom movements?

It will make my code a bit more complex since I will also have to keep track of what the handleEvent function returned during the last mouse event, but it could be an optimization if the mouse generates a lot of mouse events.

Not sure how to check that really? If you haven't had similar problems it might be specific to something in my hardware. I'm just planning to leave the delay set to 0, seems like a lot less work and I don't really need a delay for my project.

texus

I just mean printing the mouse position every time you get a mouse move event and see if you get duplicates.

I've noticed in the past that if I move my mouse very slowly then I could get multiple MouseMoved events with the same mouse position (after a few events it does move a pixel of course). How many events are generated may depends on the hardware. So it would be interesting for me to know if when you move your mouse fast, slowly or even not moving it at all if the mouse coordinate in the MouseMoved is sometimes the same multiple events in a row. If there are several duplicates then it might be worth only handling the changes in my handleEvent function and drop duplicates.