TGUI Forum

General Category => Help requests => Topic started by: roccio on 15 May 2018, 16:58:19

Title: v0.8-dev - Picture signals
Post by: roccio on 15 May 2018, 16:58:19
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.

Code: [Select]
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?
Title: Re: v0.8-dev - Picture signals
Post by: texus on 15 May 2018, 17:53:43
The code works fine when I change printf to cout like this:
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.
Title: Re: v0.8-dev - Picture signals
Post by: roccio on 16 May 2018, 09:18:19
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)
Title: Re: v0.8-dev - Picture signals
Post by: texus on 16 May 2018, 18:09:54
What does "tgui::getDoubleClickTime()" return?