Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Clickable text within a text link (like http a href markup)

Author
Message
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 2nd Nov 2014 04:19
Over on the v2 feature request thread @TimShark suggested that we have the ability to make links within a text object that could specifically be clicked on and do something.
Since it was something I've been meaning to implement in Wordspionage for the "Message from HQ" messages we send out I decided to go ahead and work up an example to show folks how this can be achieved.
What this does is it takes a specially formatted string, parses it for a URL and it's accompanying tag, then colors it and underlines it so it looks like an html markup link <a href>. It includes some handy color functions that I commonly use, a function to test for hits on the link part of the text. It stores the position of the link within the text object by use of a UDT. I'm certain other methods, maybe even simpler ones, are available.

This is all in v2 so some minor adjustments may be needed for v1.
It is also in percentage mode, if you want to do it with virtual resolution then modify as needed!
Main:


#include "clickable_text.agc"



Other items to consider:
If you want to BOLD some text you could employ a similar method of finding the position of the text to be bolded, setting the alpha on the characters in the original text to 0 and overlaying them with a new text object using a bold font. Same with italics. Not too painful, took me less than an hour to work this up. I can only imagine what some of you can do with it!

It'd be nice to see a more complete library of text formatting functions like this, but everyone has their own needs and those are difficult to predict. So if you do make functions like this it might be nice to save a fellow dev some time and post them up in the forum.

I hope this helps some of you

Native Tech
10
Years of Service
User Offline
Joined: 19th Jul 2013
Location:
Posted: 2nd Nov 2014 07:34
Nice work , you and I code in a very very similar fashion ,I'm digging this AppGameKit language

Native Technology
Timshark
16
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 2nd Nov 2014 16:13
@ Naphier

Thank you for this Enlightenment! You are right. We do have the tools to do many things already. You pointed my brain in the right direction.

Nice work.

I never want what I know.
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 2nd Nov 2014 19:53
Timshark
16
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 3rd Nov 2014 04:25
I banged together a quick test for coloring words under the pointer..



I never want what I know.
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 3rd Nov 2014 05:07
Timshark
16
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 18th Nov 2014 04:11
@ Naphier

I´m heavy into text these days and after a lot of testing I´ve concluded that I like some way of getting the character (index)number for the first character in a getStringtoken(). This would make it very easy to apply it to getTextCharX() or getTextCharY() or Mid().

I never want what I know.
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 18th Nov 2014 04:25
for each string token before the one to "select" get the length and add 1 to it for the token itself.

So
names$ = "john,jane,joe,mike"
I want the position of the first character in 'mike'
tokenCount = CountStringTokens(names$ , ",") //would be 4
mikeTokenNum = 0
for i = 1 to tokenCount
if GetStringToken(name$ , "," , i) = "mike"
mikeTokenNum = i
exit
endif
next i

charsToMikeToken = mikeTokenNum - 1
for i = 1 to mikeTokenNum - 1
charsToMikeToken = charsToMikeToken + len(GetStringToken(name$ , "," , i))
next i

And so forth.

Timshark
16
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 18th Nov 2014 04:49 Edited at: 18th Nov 2014 04:56
This is what I´m doing but I want to use multiple delimiters. Like linefeed (chr(10)) ".,!?" etc. And since I´m making an editor I have to make sure it fits a lot of strings setups. I need to know the words char position without ",.!?" and chr(10) but also need to include these characters in the text.

I need the Textstring to look like it was written but need the StartX,StartY,EndX,EndY of the individual words without the linefeed or ",.!?"

I never want what I know.

Login to post a reply

Server time is: 2024-03-29 13:30:53
Your offset time is: 2024-03-29 13:30:53