Editbox does not return entered text

Started by mihaiflorea, 12 June 2014, 07:30:42

mihaiflorea

Hello! I have a problem with an Editbox whitch does not return anything but  text i set with edit_box->setText("hello");. I created the widget from form. The strange thing is i have many widgets of this type whitch are working, but this is driving me crazy. I have the same code, the same structure for all.  Is there a general problem like this with those editboxes?

This is how i get the text from editbox.

tgui::EditBox::Ptr           nume= gui->get("numeDeAnulat"),
prenume= gui->get("prenumeDeAnulat"),
cnp= gui->get("cnpDeAnulat");

std::string xnume= nume->getText().toAnsiString(),
xprenume= prenume->getText().toAnsiString(),
xcnp= cnp->getText().toAnsiString();

texus

If it works for some edit boxes and not for that one then it can't really be a bug in tgui (at least not an obvious one like getText always returning an empty string). So I will need a minimal but complete example that reproduces the problem, since the lines you showed seem to be fine.

mihaiflorea

I have a class that contains all widgets i need in a window, saved in a gui pointer.
Gui pointer is gonna be drawn in a window later.
This is the method which uploads my widgets from file :
void upload_window()
{
gui->setGlobalFont("DejaVuSans.ttf");

gui->loadWidgetsFromFile("anulareRezervareForm/anulareRezervare.txt");


}


This is the complete code that takes text from editboxes:
int colect_data()
{
if (data)
delete data;

data=new AnulareRezervare;

tgui::EditBox::Ptr  nume= gui->get("numeDeAnulat"),
prenume= gui->get("prenumeDeAnulat"),
cnp= gui->get("cnpDeAnulat");

std::string xnume= nume->getText(),
xprenume= prenume->getText(),
xcnp= cnp->getText();

data->nume= strdup(xnume.c_str());
data->prenume= strdup(xprenume.c_str());
data->cnp= strdup(xcnp.c_str());

return success;
}


I verified entire code  and it seems to be fine, but when i enter a text in any editbox from my window, i get only the text i set with setText() or in the form config. I tried with a textbox, but the same thing i get, in this window, all of my widgets are not working correctly.



texus

#3
I really need a full code to test (minimized if possible), because the code you show seems perfectly fine. I just tested and the getText function works like it should.

The only thing that I can think of that could cause this behaviour is that you are copying the Gui instance somewhere. You would be using one to draw on the screen and handle events, while you are calling the get function on the different Gui instance.

Edit: Another thing is that you perhaps call upload_window twice and thus loadWidgetsFromFile is called twice? Try putting "gui.removeAllWidgets();" before the loadWidgetsFromFile call and see if that fixes it.