Add IsFocused equivalent in Gui class

Started by wizzard, 06 January 2015, 13:02:40

wizzard

I want to know if any widgets in a Gui have focus. If not, I allow my game engine to handle events. I currently do this by looping through all the widgets in the Gui. I was disappointed to see how Gui::hasFocus worked.

texus

The hasFocus function on the Gui object was only added because sfml did not yet have a way to check which window is focused. So it is indeed entirely unrelated.

But I don't want to add such a function because I don't like the focusing part of my gui in general. It has to be completely redesigned to be useful. So maybe one day something like that will be added.

I even thought that some widget is always focused in the gui, so you should be glad that you can even detect it with the way you currently do :)

I really don't know yet which direction my gui will take. I think the focus system as it exists now might even completely disappear in the future. But I don't have time to think about these things, I'm in the middle of my exam period.

wizzard

Good luck with exams! I hope my way keeps working with all types of widgets.

texus

#3
I just remembered something. The handleEvent function returns a boolean value telling whether the event was consumed by tgui. So if you receive a sf::Event::TextEntered event then you could just check the return value of handleEvent. If it returns false then your game engine can continue with the event.

QuoteGood luck with exams!
Thanks.

Edit:
I knew I implemented this for someone, but apparently I did it for you. So I guess you might already know that option :)