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

Author Topic: Generate Event::Closed programatically?  (Read 2561 times)

0 Members and 1 Guest are viewing this topic.

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Generate Event::Closed programatically?
« on: July 10, 2014, 06:07:08 am »
Hi, so I'm looking for a way to create the sf::Event::Closed event without manually doing anything like pressing the close window button or alt+F4.

From what I can tell, all the ways a user could push custom events are private and hidden, unfortunately!!! Well, unless I mod the SFML source of course, but that's undesirable.

For my testing purposes it would be very convenient to be able to generate events in the code somehow in general, but for the moment I'm specifically looking for a way to make the program emit the Event::Closed event. Is it possible?
« Last Edit: July 10, 2014, 06:08:58 am by Mårran »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Generate Event::Closed programatically?
« Reply #1 on: July 10, 2014, 08:01:15 am »
No, this is not possible.

But why would you like to emit this event, instead of directly doing what you do when you receive it?
Laurent Gomila - SFML developer

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: Generate Event::Closed programatically?
« Reply #2 on: July 10, 2014, 11:03:50 am »
I would use it to automate the testing of the event handling aspect of something I'm working on. I realize it's possible call the functions directly as you say, but it would be a better test to do so via emitting the actual events instead.

Also I don't think it's too weird or unreasonable to be able to push any event in general, and especially custom ones. For example I think SDL has that option if I recall correctly. One use case I can think of is to let the developer create custom events as an easy mechanism for deferring some action to the next iteration of the update loop, which I believe is not uncommon to want to do in a game application.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Generate Event::Closed programatically?
« Reply #3 on: July 10, 2014, 11:32:19 am »
Also I don't think it's too weird or unreasonable to be able to push any event in general
You can easily build your own event queue on top of SFML's if you need that. The job of sf::Window::pollEvent() is to give you the actual OS events, and nothing more.

If you happen to user Thor, its ActionMap class also lets you push custom events.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Mörkö

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: Generate Event::Closed programatically?
« Reply #4 on: July 10, 2014, 12:09:07 pm »
Okay, well my question about events is answered in any case, thank you.

Quote
If you happen to user Thor, its ActionMap class also lets you push custom events.

I'm probably going to try Thor later, after I have a full working knowledge of SFML.
« Last Edit: July 10, 2014, 12:23:39 pm by Mårran »