v0.8-dev - Picture signals

Started by roccio, 15 May 2018, 16:58:19

roccio

Hello again :)
I have a problem with the picture widget. I am trying to connect it with a DoubleClicked signal, but it seems not to fire.


int Test()
{
sf::RenderWindow window;
tgui::Gui gui;

window.create(sf::VideoMode(800, 600), "test", sf::Style::Close);
window.setFramerateLimit(60);

gui.setTarget(window);

sf::Texture texture;
texture.loadFromFile("images\\tgui-logo.png");

tgui::Picture::Ptr picture = tgui::Picture::create();
picture->getRenderer()->setTexture(texture);
picture->connect("DoubleClicked", []() {printf("Pressed"); });
gui.add(picture);

while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
return 0;

gui.handleEvent(event);
}
window.clear(sf::Color(223, 223, 223));
gui.draw();
window.display();
}

return 1;
}


Am I missing something?

texus

#1
The code works fine when I change printf to cout like this:
Code (cpp) Select
picture->connect("DoubleClicked", []() { std::cout << "Pressed" << std::endl; });

The std::endl flushes the output stream immediately while printf doesn't, so I guess it was working but you just weren't seeing the output (as it was still buffered).

Edit: Adding "\n" at the end of the printf string also works.

roccio

Sorry, but the test code was made just for an example. In my real code I have put a breakpoint and it never stops.
I have tried to change the test with std::cout as you wrote, but I got nothing in my console (neither stops if I put a breakpoint in the function).

I am using VC2015 under windows 10 (1803)

texus

What does "tgui::getDoubleClickTime()" return?