Help with gui::get(), list boxes and tabs
« on: 21 November 2015, 18:43:18 »
Hello. I set up some code like this:

tgui::ListBox::Ptr list_box_ptr = gui->get("List Box");

And I'm getting an error which reads "no conversion from tgui::Widget to tgui::ListBox exists"

But if I change the code to:

tgui::Widget::Ptr list_box_ptr = gui->get("List Box");

I lose the member functions available to tgui::ListBox.

How do I retrieve a pointer to a listbox (or any other widget) using get? Do I have to cast it into the right type of pointer each time?

Another thing, how do I work with tabs? There's nothing about them in the tutorials.

Is there some sample code anywhere, with basic usage of each widget? That would ease the use of the library a lot. I want to set up some tabs and listboxes...
« Last Edit: 21 November 2015, 18:50:32 by desocupado »

*

texus

  • *****
  • 1151
    • View Profile
    • Texus's Blog
Re: Help with gui::get(), list boxes and tabs
« Reply #1 on: 21 November 2015, 18:53:34 »
Quote
How do I retrieve a pointer to a listbox (or any other widget) using get?
You could cast the returned value yourself with std::static_pointer_cast or std::dynamic_pointer_cast, but there is a templated get function which will do the static cast for you:
tgui::ListBox::Ptr list_box_ptr = gui->get<tgui::ListBox>("List Box");

Quote
Another thing, how do I work with tabs? There's nothing about them in the tutorial.
tgui::Tab::Ptr tab = std::make_shared<tgui::Tab>();
tab->add("First");
tab->add("Second");
tab->add("Third");
gui.add(tab);

Quote
Is there some sample code anywhere, with basic usage of each widget? That would ease the use of the library a lot.
I simply do not have enough time to write tutorials or example codes for everything. The only thing you can do to learn how a widget works right now is to check its functions in the documentation. (e.g. for Tab: https://tgui.eu/documentation/v0.7/classtgui_1_1Tab.html#pub-methods)

Re: Help with gui::get(), list boxes and tabs
« Reply #2 on: 21 November 2015, 23:49:14 »
Well, thanks for the answers! :)

I hope you don't mind if I have more questions tho.

For example, is there a way to make all tabs the same, fixed width, regardless of the text width?

*

texus

  • *****
  • 1151
    • View Profile
    • Texus's Blog
Re: Help with gui::get(), list boxes and tabs
« Reply #3 on: 21 November 2015, 23:50:54 »
Quote
is there a way to make all tabs the same, fixed width, regardless of the text width?
It is planned before the final release of v0.7, but you shoudn't expect it soon: https://github.com/texus/TGUI/issues/42