Help with gui::get(), list boxes and tabs

Started by desocupado, 21 November 2015, 18:43:18

desocupado

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...

texus

QuoteHow 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:
Code (cpp) Select
tgui::ListBox::Ptr list_box_ptr = gui->get<tgui::ListBox>("List Box");

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


QuoteIs 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)

desocupado

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

Quoteis 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