TextBox, Button and Functions.
« on: 13 April 2019, 19:33:46 »
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

  • *****
  • 1342
    • View Profile
    • Texus's Blog
Re: TextBox, Button and Functions.
« Reply #1 on: 13 April 2019, 19:44:28 »
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:
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.

Re: TextBox, Button and Functions.
« Reply #2 on: 16 April 2019, 14:42:06 »
Thanks.