Blinking ToolTips
« on: 18 November 2016, 18:55:18 »
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Blinking ToolTips
« Reply #1 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:
if ((event.type == sf::Event::MouseMoved) || (event.type == sf::Event::MouseButtonPressed)
 || (event.type == sf::Event::MouseButtonReleased) || (event.type == sf::Event::MouseWheelMoved))

Re: Blinking ToolTips
« Reply #2 on: 18 November 2016, 19:15:32 »
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:
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Blinking ToolTips
« Reply #3 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).

Re: Blinking ToolTips
« Reply #4 on: 18 November 2016, 19:27:11 »
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.
« Last Edit: 18 November 2016, 19:32:43 by MoLAoS »

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Blinking ToolTips
« Reply #5 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:
std::cout << ((event.type == sf::Event::MouseMoved) || (event.type == sf::Event::MouseButtonPressed)
 || (event.type == sf::Event::MouseButtonReleased) || (event.type == sf::Event::MouseWheelMoved)) << std::endl;

Re: Blinking ToolTips
« Reply #6 on: 18 November 2016, 19:46:47 »
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:
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Blinking ToolTips
« Reply #7 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.

Re: Blinking ToolTips
« Reply #8 on: 18 November 2016, 20:09:19 »
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Blinking ToolTips
« Reply #9 on: 18 November 2016, 22:37:54 »
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.