Right, "vetoing" mechanism. Maybe it worth to mention about the behaviour in documentation or gather such non-always obvious questions in special FAQ topic on the forum.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
#include <TGUI/TGUI.hpp>
#include <iostream>
class MyFrame
{
public:
MyFrame()
{
window.create(sf::VideoMode(800, 600), "TGUI window");
gui.setTarget(window);
panel = tgui::Panel::create();
auto b = tgui::Button::create();
b->setText("Click");
b->connect("pressed", [this]()
{
auto ptr = tgui::ChildWindow::create("Test");
ptr->connect("Closed", [this, ptr]()
{
std::cout << ptr->getTitle().toAnsiString() << '\n';
//ptr->destroy(); // all works if uncomment
});
panel->add(ptr);
});
panel->add(b);
gui.add(panel);
}
void main()
{
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
gui.handleEvent(event);
}
window.clear();
gui.draw();
window.display();
}
}
private:
sf::RenderWindow window;
tgui::Gui gui;
tgui::Panel::Ptr panel;
};
int main()
{
MyFrame().main();
}
#include <TGUI/TGUI.hpp>
class MyFrame
{
public:
MyFrame(int argc, char* argv[]);
void main();
protected:
tgui::Button::Ptr m_Button;
private:
sf::RenderWindow window;
tgui::Gui gui;
};
MyFrame::MyFrame(int argc, char* argv[])
{
window.create(sf::VideoMode(800, 600), "TGUI window");
gui.setTarget(window);
auto panel = tgui::ScrollablePanel::create();
m_Button = tgui::Button::create("Press");
panel->add(m_Button);
gui.add(panel);
}
void MyFrame::main()
{
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
else if (event.type == sf::Event::Resized)
{
window.setView(sf::View(sf::FloatRect(0.f, 0.f, static_cast<float>(event.size.width), static_cast<float>(event.size.height))));
gui.setView(window.getView());
}
gui.handleEvent(event);
}
window.clear();
gui.draw();
window.display();
}
}
int main(int argc, char* argv[])
{
MyFrame f(argc, argv);
f.main();
}