Creating buttons inside a panel

Started by Zacirus, 09 May 2015, 00:42:22

Zacirus

I am trying to develop a program that handles inputs in different tabs. This tabs shows and hides different panels.
I want to show different EditBoxes depending on what tab is shown.
The tabs, panels and EditBoxes are created outside main in void loadWidgets(tgui::Gui& gui)

This works if I create the buttons like this; tgui::EditBox::Ptr editBoxModelName(*panel1, "modelName");

But if I do it like that I can't get the value in main from the editBox using; tgui::EditBox::Ptr editBoxModelName = gui.get("modelName");
sf::String modelName = editBoxModelName->getText();
  (Assertion failed: m_WidgetPtr != nullptr

If I use gui instead of *panel1 when I create my EditBox I can get the value, but of course the EditBox is shown on all my tabs.

How am I supposed to handle this?
I don't think I have to say that I am a beginner on this :P

Thanks in advance!

texus

The get function will look only at the direct children of the widget by default. Since the edit box is not a direct child of gui, it will not find it.

Every container widget actually has a get function, not just Gui, so you would have to do this:
Code (cpp) Select
panel1->get("modelName");

I also added an option for get to search recursively some time ago, so this is also an option:
Code (cpp) Select
gui.get("modelName", true);

Zacirus

This worked great!
Thanks a lot for the fast and great support :)