TextBox, Button and Functions.

Started by _4004, 13 April 2019, 19:33:46

_4004

Hello. I new on tgui. I When I press the button, I want the TextBox to be sent to the "merhaba" function, but it gives an error.

texus

The merhaba function takes 2 parameter, neither of which the Button should provide (i.e. the last parameter isn't a string that should contain the caption of the button), so you have to provide both parameters to the connect function:
Code (cpp) Select
button->connect("pressed", &merhaba, std::ref(window), i);

The "i" value will however be copied, so the merhaba function will always be called with the same value.
If you want to get the value of the edit box at the moment you press the button then you should pass "yazialani" instead of "i" to the connect function (and change merhaba to take a tgui::EditBox::Ptr as second parameter) and put the "int i = std::atoi(yazialani->getText().toAnsiString().c_str());" at the start of the merhaba function.