Stop selection point from flashing when window does not have focus

Started by wizzard, 21 September 2013, 22:29:31

wizzard

I keep getting fooled into thinking that I can type in my client window when it isn't selected.
This is because the caret is flashing even though the window does not have focus.
The EditBox should still use its focused images, but I just wish that the selection point would stop flashing.

wizzard

To implement this, TGUI would need to keep track of whether the SFML window has focus using its events
When the SFML window does not have focus, the selection point would not be drawn ever

Edit:
It might also be worth exposing the function with tgui::Gui::hasFocus

texus

This is actually your responsibility. Your program is still running in the background.

When the window loses focus you should ignore all events (and don't call gui.handleEvent) until the window gets focused again.

wizzard

The flashing of the selection point happens via mainWindowGui.draw() though

Edit: By the way, I tried it just in case it oddly worked

wizzard

I guess the first post is a bit confusing...

When the SFML render window does not have focus, the TGUI edit box has a flashing caret.
I just want it stop flashing when the SFML render window is not focused.
The point I was trying to make up above is that the TGUI edit box should still be focused regardless.
However, the little flashing caret should stop flashing when you can't type into the box.
If the SFML render window does have focus again, I would be able to type into the box.
So, the flashing caret would depend on whether or not the SFML render window has focus.

texus

I didn't have much time earlier, so just ignore my previous answer.

I'm now blocking the update function when the window isn't focused, so any animation (at this point only the flashing caret) will be paused as long as the window is unfocused.

There is only one small thing, I don't know if the window is going to be focused when the program starts. This is something that might be OS-dependant (and I only tested on linux so far) so let me know when the caret doesn't flicker at all.

wizzard

Thanks for this change! I will notify you if there is some weird behavior on Windows.
(but I'm pretty sure the window is focused at first on all Windows platforms)