*

texus

  • *****
  • 1342
    • View Profile
    • Texus's Blog
Re: Switching to 0.7
« Reply #15 on: 09 October 2014, 16:55:21 »
You could create an extra boolean in your function, e.g. called "running".

If you e.g. want to change the running variable when a button is pressed you can do
Code: [Select]
button->connect([&](){ running = false; });
If your callback function contains too much code for being a lambda function you could pass the running variable by reference.
Code: [Select]
void myFunction(bool&);
button->connect(myFunction, std::ref(running));

Another solution might perhaps be not to have the main loop inside your state.
Your state should have the functions like handleEvent, update an draw while the main loop just calls these functions on the active state.