Assign unique identier to a vector of Panels
« on: 28 March 2015, 05:49:58 »
Hi Folks,

So I have a vector of panels as below.

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?

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

Re: Assign unique identier to a vector of Panels
« Reply #1 on: 30 March 2015, 19:19:34 »
just wondering if anyone has any ideas on this one?

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Assign unique identier to a vector of Panels
« Reply #2 on: 30 March 2015, 19:52:54 »
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.
gui.getWidgetName(PanelList.back(), test);

Re: Assign unique identier to a vector of Panels
« Reply #3 on: 02 April 2015, 01:40:42 »
Awesome - thank you so much. Obvious now that I see it.  :-[