Started by robvleugel, 25 July 2013, 16:39:36


Question/suggestion, why two separate functions for binding and setting the callback id?
Why not button->bindCallback(tgui::Button::LeftMouseClicked, 1);
Is there ever a need for separate functions?

Imo the function could even return the callback as integer and make the second parameter (ID) optional, assigning a new unique number if not entered.

Even better would be if the button could somehow be used in the way below

//Handle callbacks
    while (m_gui.pollCallback(m_callback))
if (quitbutton.state == tgui::Button::LeftMouseClicked)


In many situations, you won't need the callback id.

It is only needed when all callback comes in place and you have to figure out where the callback came from.
If you would have menuButtonClicked and quitButtonClicked callback functions then you don't need a callback id. These functions don't even need a parameter (unless they need access to certain variables).

The way you are handling callbacks can be considered the 'old' (and easiest) way, it was the only way to handle callbacks in v0.5. But as you can see in the callbacks tutorial, you no longer have to poll the callbacks from the gui and depending on your code and situation an id isn't needed.

Not every widget has a state and I think you might be able to miss events (by the time you reach that code the mouse might have gone up already).