going from 0.8 -> 1.0 tgui onTextChange()

Started by pmiloslavsky, 23 September 2023, 02:36:03

pmiloslavsky

How do I have my own custom signal for EditBox with 2 parameters, and what the text changed to on the end in the last parameter?

 auto editBox = tgui::EditBox::create();
 editBox->onTextChange(signalPower, p_model, pgui);

in signalPower I want to see the value of the text.
Do I need to pass editBox and then call getText() inside signal?

In the 0.8 old way the const String was a last implicit parameter.

texus

QuoteIn the 0.8 old way the const String was a last implicit parameter.

This way still exists. What changed is that the parameter now needs to have type tgui::String instead of sf::String.

Starting with TGUI 0.9, I made TGUI's code independent from SFML, so I have my own types for things like Vector2f and String now (partially also because I disliked how sf::String handled UTF-8, tgui::String will consider all char* or std::string as UTF-8 strings). There are constructors and conversion operations between the SFML and TGUI classes, so if inside your callback you really need an sf::String, because you e.g. need to pass the text to SFML, then you can create it with "sf::String sf_str(tgui_str);".

QuoteDo I need to pass editBox and then call getText() inside signal?

For information that isn't included in the implicit parameter (i.e. anything other than the text), this would be the solution.


pmiloslavsky

Thank you for the explanation. Its working now.