Assign unique identier to a vector of Panels

Started by starkhorn, 28 March 2015, 05:49:58

starkhorn

Hi Folks,

So I have a vector of panels as below.

Code (cpp) Select

vector<tgui::Panel::Ptr> PanelList;


So depending on whatever menu or phase needs to be displayed, then panels are added and removed from this PanelList.
Now I need a way to be able to identify each panel, ideally with a string but not fussed. I tried adding widget name but when I call the getWidgetName, it always seem to return blank.

As below, I push_back a new panel to gui and also construct it with a passed in string for the widgetname.
I then tried to get the widget name but I always get blank. I've tried getWidgetName and Names. Obviously I think I'm not using them correctly. Any ideas what I'm doing wrong?

Code (cpp) Select

PanelList.push_back(tgui::Panel::Ptr(gui, passed_panelName));
string test;
PanelList.back()->getWidgetName(PanelList.back(), test);

starkhorn

just wondering if anyone has any ideas on this one?

texus

Sorry for replying so late, but for some reason I didn't get any notification for this topic.

getWidgetName is a function in Container, not Widget, so it is intended to be called on a parent widget. With that function you ask the panel for the name of one of the widgets that it contains. The panel doesn't contain itself so it returns false and doesn't set a name.

So you must call getWidgetName on the parent of the panel.
Code (cpp) Select
gui.getWidgetName(PanelList.back(), test);

starkhorn

Awesome - thank you so much. Obvious now that I see it.  :-[