Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Adding Events to the Event queue  (Read 2727 times)

0 Members and 1 Guest are viewing this topic.

Valeour

  • Newbie
  • *
  • Posts: 19
    • View Profile
Adding Events to the Event queue
« 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?
Check out my blog; Technical Daze

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Adding Events to the Event queue
« Reply #1 on: October 07, 2011, 07:47:11 am »
Why don't you use the event (signal/slot) system of GWEN?

Code: [Select]
quitButton->onPress.Add(&window, &RenderWindow::Close);
Laurent Gomila - SFML developer

Lee R

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
Adding Events to the Event queue
« Reply #2 on: October 07, 2011, 04:47:27 pm »
Quote from: "Laurent"
Why don't you use the event (signal/slot) system of GWEN?

Code: [Select]
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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Adding Events to the Event queue
« Reply #3 on: October 07, 2011, 06:12:00 pm »
Quote
In that case, RenderWindow would have to derive from Gwen::Event::Handler

Really? Their event handling system sucks...
Laurent Gomila - SFML developer

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Adding Events to the Event queue
« Reply #4 on: October 08, 2011, 01:29:27 am »
Indeed. I kind of make love with libsigc++ . If you 're looking for signal slot systems, i really vote on it :)

Valeour

  • Newbie
  • *
  • Posts: 19
    • View Profile
Adding Events to the Event queue
« Reply #5 on: October 15, 2011, 06:52:33 pm »
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.
Check out my blog; Technical Daze