Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Feature requests / Multiple selection items for ListView.
« Last post by Kvaz1r on 01 October 2019, 16:25:29 »
In some cases there is important to have opportunity select several items from the list (for example if its file picker dialog).
22
Help requests / Re: Using canvas
« Last post by texus on 28 September 2019, 14:26:25 »
The "tgui-git" package downloads directly from github, so updating that package always gives the latest github version.
23
Help requests / Re: Using canvas
« Last post by CatalinNic on 28 September 2019, 11:23:57 »
I will see if it is an update on AUR
24
Help requests / Re: Using canvas
« Last post by texus on 28 September 2019, 11:19:08 »
I didn't test to make sure that it actually works, but I have added a setView function (and getters) to the Canvas class in the latest version on github.
25
Help requests / Re: Using canvas
« Last post by CatalinNic on 28 September 2019, 10:41:55 »
I want to use it for testing level like this: .And the level itself is a lot bigger than the canvas
26
Help requests / Re: Using canvas
« Last post by texus on 28 September 2019, 10:35:50 »
It currently doesn't has a view. But I could add it as the class is a wrapper around sf::RenderTexture which does seem to have a view. What are you trying to do exactly?
27
Help requests / Using canvas
« Last post by CatalinNic on 28 September 2019, 10:22:57 »
I try to use a canvas and I don't know if it is possible to set view? if it is, how?
28
Help requests / Re: Get a widget
« Last post by CatalinNic on 27 September 2019, 18:43:44 »
Done it all I need to do was to use gui.remove(gui.get(WidgetName)) to propery remove it.
29
Help requests / Re: Get a widget
« Last post by CatalinNic on 27 September 2019, 18:30:38 »
And curious, how i can delete a widget if the only way to access it is by using the get function without crashing the whole program? (I hope that's pretty specific).
30
Help requests / Re: Get a widget
« Last post by texus on 25 September 2019, 22:28:49 »
When you add a widget to the gui, you can optionally pass it a name.
gui.add(widget, "UniqueName");

Passing that name to the get function will return the widget:
tgui::Widget::Ptr widget = gui.get("UniqueName");

The normal get function returns a pointer to the Widget class, which is the base class for all widgets. Often you need access to the functions of a derived type (e.g. for setting the text of a button), in which case you need to cast it:
tgui::Button::Ptr button = widget->cast<tgui::Button>();

There is however also a get function that does both of these operations at once: it retrieves the widget by its name and casts it to the right type. It is called like this:
tgui::Button::Ptr button = gui.get<tgui::Button>("UniqueName");

Obviously, the widget with name "UniqueName" has to be a Button, if it was e.g. an EditBox then it might fail.
(I'm not sure if I made any guarantees about what would happen. Right now I believe it will just return a nullptr, but it is possible that it could change to e.g. assert in the future. So just don't use the wrong type.)

The same holds for any container widget. If you have a Group, Panel, ChildWindow or any other widget that inherits from the Container class then you can use the get functions on them too, just replace the "gui." in the examples above with "container->"
Pages: 1 2 [3] 4 5 ... 10