I'm looking for a way to see if the close button in a child window title bar has been pressed. Is there a hard-coded callback ID for example? Basically as well as just closing the child window, I also want to trigger other events as well.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
It has a Closed trigger which you can bind.
childWindow->bindCallback(tgui::ChildWindow::Closed);

If the Closed trigger is not bound, then clicking the close button will close the window. However, once you bind the close button you will get the ability to keep it open, so you will have to close it yourself. Either childWindow->destroy() or parent.remove(widget) will do that. The callback class contains a "widget" pointer which can be used for the remove.
gui.remove(callback.widget);

Hi Texus,

I'm really confused on this one. So I set the callback as above ,i.e.

childWindow->bindCallback(tgui::ChildWindow::Closed);
 

Then in the gui.pollCallback loop, I'm checking if this callback id is hit, i.e.

                        if (callback.id == tgui::ChildWindow::Closed)
                        {
                                int test = 0;
                        }
 

However this doesn't get triggered - so I'm a bit confused here as to why I'm unable to detect when the closed child window is pressed.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
callback.id contains the number that you can change with childWindow->setCallbackId. What you need is callback.trigger which will equal the tgui::ChildWindow::Closed.

ahhh - ok I see. Thank you yet again.