Gui scripting Documentation?
by Anthony Merlo · in Torque 3D Professional · 04/28/2011 (8:52 am) · 4 replies
Can someone point me in the direction of a decent source of complete documentation for designing GUI's in Torque 3D? Not just how to use the editor, but scripting dynamic data to populate text based gui's.
All of the information I'm finding is either incomplete or very outdated.
What I'm trying to do is design a simple list of items that can be clicked on but also be different colors. Like one line item will be white if it can be used and another line item will be greyed out if it can't be used.
Using GuiTextCtrl it seem I can get a list like I want but I can't make each line a different color.
Using GuiMLTextCtrl I can make each line a different color using the markup language but I can't click on them to execute code to use the item.
I've also considered using GuiTextListCtrl but I can't find any documentation on usage. But I also think you can't have different line set to different colors.
My skill level is rather low but I'm willing to read and learn on my own rather than have someone just give me the answer, but I can't seem to find a decent source of documentation on scripting syntax and usage. What I'm able to find is Info for either TGE (incomplete) or fragments of usage in resources posted here.
Thanks in advance for any assistance you may be able to offer.
All of the information I'm finding is either incomplete or very outdated.
What I'm trying to do is design a simple list of items that can be clicked on but also be different colors. Like one line item will be white if it can be used and another line item will be greyed out if it can't be used.
Using GuiTextCtrl it seem I can get a list like I want but I can't make each line a different color.
Using GuiMLTextCtrl I can make each line a different color using the markup language but I can't click on them to execute code to use the item.
I've also considered using GuiTextListCtrl but I can't find any documentation on usage. But I also think you can't have different line set to different colors.
My skill level is rather low but I'm willing to read and learn on my own rather than have someone just give me the answer, but I can't seem to find a decent source of documentation on scripting syntax and usage. What I'm able to find is Info for either TGE (incomplete) or fragments of usage in resources posted here.
Thanks in advance for any assistance you may be able to offer.
#2
Maybe I did something wrong, but if I try this it opens up a web browser and tries to load a page called "http://samplefunction/".
I don't think it is getting to the onURL.
04/30/2011 (2:23 pm)
Thanks for the reply!Maybe I did something wrong, but if I try this it opens up a web browser and tries to load a page called "http://samplefunction/".
I don't think it is getting to the onURL.
#3
04/30/2011 (2:44 pm)
Sounds like you put "http://samplefunction" into that <a> tag, because I get "sampleFunction" as echo'ed output to the console. To clarify, when I said you shouldn't break the html formatting, what I meant is that you shouldn't put any characters into that tag that makes the <a> tag unable to render as a clickable hyperlink. You don't, however, have to put anything as the link itself except what you want to use as data. Try it as it's written first (and change the visible for the GuiMLTextCtrl to "1"- I updated that in my post). Let me know if that fixes it.
#4
Is there a way to get rid of the underline and not use URL colors, so it just looks like plain text that you can click on rather than a hyper-link with an underline? It seems to be ignoring the <color> but <font> seems to work.
I can see in the source of the guiMlTextCtrl.cpp:
and
But I'm not sure how to set these in the profile/gui.
Thanks Again!
04/30/2011 (4:32 pm)
Actually it was a simple fix. I mistakenly referenced the parent gui name in the onURL function. I changed it to the correct name it it works fine.Is there a way to get rid of the underline and not use URL colors, so it just looks like plain text that you can click on rather than a hyper-link with an underline? It seems to be ignoring the <color> but <font> seems to work.
I can see in the source of the guiMlTextCtrl.cpp:
if(atom->url)
{
if(atom->url->mouseDown)
color = atom->style->linkColorHL;
else
color = atom->style->linkColor;
}
else
color = atom->style->color;and
if(atom->url && !atom->url->noUnderline)
{
drawPoint.y += atom->baseLine + 2;
Point2I p2 = drawPoint;
p2.x += font->getStrNWidthPrecise(tmp, end - atom->textStart);
drawer->drawLine(drawPoint, p2, color);
}But I'm not sure how to set these in the profile/gui.
Thanks Again!
Torque 3D Owner Ted Southard
Sure you can:
new GuiMLTextCtrl(testML) { canSaveDynamicFields = "0"; isContainer = "0"; Profile = "GuiMLTextProfile"; HorizSizing = "right"; VertSizing = "top"; Position = "0 0"; Extent = "300 100"; MinExtent = "300 100"; canSave = "1"; Visible = "1"; text = "<a:sampleFunction>ClickityClick!</a>"; }; //This is called when you click on a hyperlink function testML::onURL(%this, %data) { //One option is to call the function and pass %data as an argument commandToServer('someFunction', %data); //Another option is to use %data like a function eval(%data @ "();"); //<- I don't know if putting full function syntax //in an <a> tag will break the html formatting, so //I add it here... } //Called explicitly with %data as an argument function serverCmdSomeFunction(%client, %data) { //Do something with %data here... echo(%data); } //Function evaluated from the %data contained in the <a:> tag function sampleFunction() { //Do stuff here... echo("sampleFunction"); }That should work. I haven't tested the eval stuff out, but I use the commandToServer method for one of my projects, and don't see why the eval won't work as well (as long as you don't break that html formatting). Hope that helps.