SFML community forums
Help => General => Topic started by: Valeour on October 06, 2011, 11:34:33 pm
-
It's that time again where I ask a possibly stupid question;
Okay, I'm using GWEN with SFML, and basically I have an inherited GWEN::Window with a button on it. I have a button on it called Exit, which I obviously want to close the application.
How do I even go about doing this? One option is to pass a pointer to the sf::renderwindow into the GWEN window, but I believe that's bad practice.
So can I either somehow add Event::Close to the event queue, or can I some how call App.Close() some how?
Basically, sf::RenderWindow < GWEN::Controls::Window < Gwen::Controls::Button. (< just being a hierarchy) How can I access sf::RenderWindow from Controls::Window?
-
Why don't you use the event (signal/slot) system of GWEN?
quitButton->onPress.Add(&window, &RenderWindow::Close);
-
Why don't you use the event (signal/slot) system of GWEN?
quitButton->onPress.Add(&window, &RenderWindow::Close);
In that case, RenderWindow would have to derive from Gwen::Event::Handler.
As an aside: I proposed an alternative system some time ago, but Garry didn't seem too interested (he asked for more details, I gave them to him but got no reply):
http://www.facepunch.com/threads/1090922?p=30462180&highlight=#post30462180
http://www.facepunch.com/threads/1090922?p=30519858&highlight=#post30519858
-
In that case, RenderWindow would have to derive from Gwen::Event::Handler
Really? Their event handling system sucks...
-
Indeed. I kind of make love with libsigc++ . If you 're looking for signal slot systems, i really vote on it :)
-
Ah, I apologise! I started Uni a few weeks ago and completely forgot about this.
So I can't quite seem to get RenderWindow::Close to work.
Any other ideas?
I'm gonna keep playing around with it, and I'll let you know if I find anything, but I doubt it.
Thank you for the replies!
Edit: Okay, I've found a simple work around.
When the button is clicked, it'll 'disable' the window that contains it.
Just before the event loop, it checks if the window is disabled, if it is, it calls Window.Close().
Sorry for wasting your time.