Game Development Community

How to get acces to a GUI in C++ class

by Gregory · in Torque 3D Professional · 11/17/2011 (7:55 am) · 2 replies

Hi,

How can i get a pointer to one of my GUI everywhere in the C++ ?

Something like that:
GuiControl* myGUI = AllGUIManager->GetByName("MyControlName");

Thanks

#1
11/17/2011 (2:18 pm)
GuiControl * myGui = NULL;
if(!Sim::findObject("MyControlName", myGUI))
{
   Con::errorf("Can't find it!");
   return;
}
Point2I pos = myGui->getPosition();
or
GuiControl * myGui = dynamic_cast<GuiControl *>(Sim::findObject("MyControlName"));
if(myGui == NULL)
{
   Con::errorf("Can't find it!");
   return;
}
Point2I pos = myGui->getPosition();

Gui names are the "public" names for whole SimObject "family". And it should be unique.
You can't do this:
new SimGroup(myCustomName);
new GuiControl(myCurtomName);
#2
11/18/2011 (6:13 am)
Thanks.