### Extanding GuiTreeViewCtrl.

There are no stupid questions, just stupid answers.

#### Extanding GuiTreeViewCtrl.

avovana
Posts: 13
Joined: Sun Feb 25, 2018 2:32 am
Hello everyone!

I have very interesting task. I'm new in the gamedev that is why asking for your help.
I need to make some kind of extention of the GuiTreeViewCtrl class.

• Map chosen Xml file into a Tree.
1. Part.
I worked a bit with the SimXMLDocument() class. I tried an example from the documentation - mapped a small Xml to the GuiTextListCtrl.
I used TorqueScript for that. It works.

Now I need to try GuiTreeViewCtrl instead GuiTextListCtrl.
Ok. I will do it to understand better how GuiTreeViewCtrl works.

2. Part.
• There should be new control class that has tree to show and a field where the information from the selected item is shown.
3. Part
1. Inherit from the GuiTreeViewCtrl;
2. Add a string(or const char*) variable for a path to the xml file - "xmlPath";
3. Add a setter - setXmlPath(const char*);
These are very first steps.
Here I have questions:
• After making this 3 steps whould I have access from the Gui Editor to call the setXmlPath() method(so via TorqueScript)?
• How to add new gui field to this class? Erm.. maybe GuiTextField to this class?

#### Re: Extanding GuiTreeViewCtrl.

avovana
Posts: 13
Joined: Sun Feb 25, 2018 2:32 am
I succesfully added new method to the class I'm playing with.

I added a new method to the class:

Code: Select all

int GuiButtonNewCtrl::getNewVar() { return newVar; }
And registered it with DefineEngineMethod:

Code: Select all

DefineEngineMethod(GuiButtonNewCtrl, getNewVar, int, (), , "Get the text display on the button's label (if any).\n\n" "@return The button's label.") { return object->getNewVar(); }
Ok. It works with int. But conceptually problem about transmission data to the class using TorqueScript is solved.

#### Who is online

Users browsing this forum: No registered users and 9 guests