Author Topic: [Resource] Text Anchors (tags)  (Read 2046 times)

This allows you to place links in GuiMLTextCtrl's to anchors that are farther down the page. When the link is clicked, the page will scroll down until the anchor is at the top of the page.

The Anchor (tag):
Quote
<tag:tagID>
TagID must be an integer.

The Link:
Quote
<a:#tagID>This is a link!</a>
TagID must be an integer that matches up with a <tag> on the page.

Example:
Quote
<tag:0>Blah blah blah this is my example page. <a:#1>Click here</a> to view cool stuff farther down the page about goldfish. You can also go <a:#2>here</a> to view other cool stuff.

-snip-

<tag:1>This is where the cool stuff about goldfish goes. When you click the link above, you'll be brought here.

-snip-

<tag:2>This is where the other cool stuff goes.

<a:#0>Click here to go back to the top of the page.</a>

This code is required:
Code: [Select]
package TextAnchors
{
function GuiMLTextCtrl::onURL(%this,%url)
{
%firstChar = getSubStr(%url,0,1);
if(%firstChar $= "#")
{
//scroll to the bottom first
//this fixes a bug in TorqueScript that makes obj.scrollToTag not work properly
%parentObj = %this.getGroup();
if(isObject(%parentObj) && isFunction(%parentObj.getClassName(),"scrollToBottom"))
%parentObj.scrollToBottom();

//now scroll back up to the tag
%restChars = getSubStr(%url,1,strLen(%url));
%this.scrollToTag(%restChars);
}
else
{
return parent::onURL(%this,%url);
}
}
};
activatePackage(TextAnchors);

This only works in GuiMLTextCtrl's that are children of GuiMLScrollCtrl's.



This is a pretty good example of its use: http://greekmods.webs.com/mods/Gamemode_Slayer/Help/help_Release.txt
« Last Edit: May 04, 2012, 07:50:05 PM by Greek2me »

Very nice, I think badspot should add in a sub forum for resources. I think it'll encourage others to actually make resources which can help developers. I know I would be encouraged.

I agree
This would probably have gone better in general discussion though

We should ask Badspot to make one. He probably won't though.

We should ask Badspot to make one. He probably won't though.

Ok make a petition and ill sign it! (im serious)

Sent him a PM.
I would like to request a "Modification Resources" board, which would be a sub-board of Blockland Modification Forums.

It would be a great place to post tutorials and coding resources like this.

I'm positive that the board would be extremely useful and that users would contribute to it by providing their own resources. Please consider it.

Thanks!


Maybe it could replace the soon-to-be outdated maps section

Maybe it could replace the soon-to-be outdated maps section
the maps section will still be useful since we'll still have maps

Oh silly me, you're right