Add IsFocused equivalent in Gui class
« on: 06 January 2015, 13:02:40 »
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

  • *****
  • 1151
    • View Profile
    • Texus's Blog
Re: Add IsFocused equivalent in Gui class
« Reply #1 on: 06 January 2015, 13:47:04 »
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.

Re: Add IsFocused equivalent in Gui class
« Reply #2 on: 06 January 2015, 21:10:04 »
Good luck with exams! I hope my way keeps working with all types of widgets.

*

texus

  • *****
  • 1151
    • View Profile
    • Texus's Blog
Re: Add IsFocused equivalent in Gui class
« Reply #3 on: 06 January 2015, 22:48:51 »
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.

Quote
Good 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 :)
« Last Edit: 06 January 2015, 23:09:54 by texus »