Bug in MessageBox
« on: 11 February 2015, 22:38:19 »
Hi Texus,

First I'd like to thank you for this amazing library. It helped me a lot that I didn't have to write my own gui logic for SFML.

Though I think I found a bug in MessageBox. In the cpp file on lines 65 and 195 when a button is clicked you send a "ButtonClicked" signal. However in the constructor (and according to the API documentation) you look for the "ButtonPressed" signal. And so if I click on the button it can't find the "ButtonClicked" signal and stops with an assert. I modified the code locally and it works for me. Could you please fix it in your dev version? Thanks in advance.

I also have another issue with messagebox (however don't know the reason). I'm setting my messagebox like this:
Code: [Select]
tgui::MessageBox::Ptr exitMsg = tgui::MessageBox::create("Gui/Black.conf");
exitMsg->setText(sf::String("Are you sure you want to quit?"));
exitMsg->addButton(sf::String("Yes"));
exitMsg->addButton(sf::String("No"));

When the messagebox appears I can't see any text neither in the window nor on the buttons, just the blank placeholders. Is there anything else I should set? Either for sf::String or for the MessageBox?

Oh and I'm using Windows 7 with MinGW 4.8.
« Last Edit: 11 February 2015, 22:40:13 by janszi »

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Bug in MessageBox
« Reply #1 on: 11 February 2015, 22:58:22 »
Quote
when a button is clicked you send a "ButtonClicked" signal. However in the constructor (and according to the API documentation) you look for the "ButtonPressed" signal.
Thanks for reporting. It has been fixed.

Quote
When the messagebox appears I can't see any text neither in the window nor on the buttons, just the blank placeholders
This could be caused by two reasons:
- Did you set a global font?
- Is the Gui/Black.conf correctly loaded? Do you get any errors in the terminal?

Re: Bug in MessageBox
« Reply #2 on: 12 February 2015, 12:08:44 »
I set the font properly, my other gui elements (button, label, editbox) work as expected. And I also don't get any message in terminal.

However I found that in MessageBox's labels (the string to show or labels of Yes, No buttons) has m_string with the proper string but in m_text is an empty m_string (type of sf::String) member. I think that's why I can't see any text, but don't know why it's empty.

Just to be clear: in my example
exitMsg->m_label.data.m_string.m_string = "Are you sure you want to quit?", but
exitMsg->m_label.data.m_text.m_string.m_string = "".
I think the second one is needed by the graphical representation.

 Any advice?

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Bug in MessageBox
« Reply #3 on: 12 February 2015, 12:34:10 »
You should show a minimal and complete example code (something that I can just copy-paste and run).

I tried these few lines from your first post yesterday and it worked fine for me. So it might be a problem somewhere else in the code.

Re: Bug in MessageBox
« Reply #4 on: 12 February 2015, 13:29:31 »
I pulled the latest dev version and it's working now. I see that you had other modification of fonts in MsgBox code. That was probably the problem. Thanks, Texus.  ;)

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Bug in MessageBox
« Reply #5 on: 12 February 2015, 13:40:33 »
Quote
I pulled the latest dev version and it's working now. I see that you had other modification of fonts in MsgBox code. That was probably the problem.
That was actually a fix for a completely different bug :) (the text was visible but the window did not resize correctly)
Good to see that it fixed this problem as well.