Here is simple code
What it does: Displays child window od given location. Problem is when clicking on [X] on childwindow, it does close child window. But it doesnt hide it or anything, so i guess child window gets destroyed automaticly. After closing the child window, and clicking on same button to show child window i get core dumped. Which i guess its becouse child gets destroyed.
1. How to implement when clicking [X] button on child window, makes child window hide(), and not destroy()
2. I know i can add buttons to child window, and bindCallback to one button to serves as hide() for childwindow, but there still will be [X] displayed in child window titlebar when displaying child window, which i cant remove, and it is dangerous if somebody click on it.
Code Select
#include <TGUI/TGUI.hpp>
void loadWidgets( tgui::Gui& gui )
{
tgui::ChildWindow::Ptr child(gui, "childWindow");
// child->load("../../widgets/Black.conf");
// child->setIcon("../icon.jpg");
child->load("Black.conf");
child->setSize(400, 400);
child->setBackgroundColor(sf::Color(80, 80, 80));
child->setPosition(200, 100);
child->setTitle("Child window");
child->hide();
tgui::Button::Ptr showChildWindow(gui);
// showChildWindow->load("../../widgets/Black.conf");
showChildWindow->load("Black.conf");
showChildWindow->setSize(120, 40);
showChildWindow->setPosition(100, 100);
showChildWindow->setText("Show child window");
showChildWindow->bindCallback(tgui::Button::LeftMouseClicked);
showChildWindow->setCallbackId(1);
}
int main()
{
sf::RenderWindow app(sf::VideoMode(800, 600), "Child window test");
tgui::Gui gui(app);
// gui.setGlobalFont("../../fonts/DejaVuSans.ttf");
gui.setGlobalFont("DejaVuSans.ttf");
loadWidgets(gui);
while (app.isOpen())
{
// Process events
sf::Event event;
while (app.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed)
app.close();
// Pass the event to all the widgets
gui.handleEvent(event);
}
tgui::Callback callback;
while (gui.pollCallback(callback))
{
if (callback.id == 1)
{
tgui::ChildWindow::Ptr Child = gui.get("childWindow");
Child->show();
}
}
// Clear screen
app.clear();
// Draw the sprite
gui.draw();
// Update the window
app.display();
}
return EXIT_SUCCESS;
}
What it does: Displays child window od given location. Problem is when clicking on [X] on childwindow, it does close child window. But it doesnt hide it or anything, so i guess child window gets destroyed automaticly. After closing the child window, and clicking on same button to show child window i get core dumped. Which i guess its becouse child gets destroyed.
1. How to implement when clicking [X] button on child window, makes child window hide(), and not destroy()
2. I know i can add buttons to child window, and bindCallback to one button to serves as hide() for childwindow, but there still will be [X] displayed in child window titlebar when displaying child window, which i cant remove, and it is dangerous if somebody click on it.