How to set font color for a word with find()?

Get help using Construct 2

Post » Sat Oct 13, 2012 9:15 pm

I would like to learn how to set font color for a word using find(src, text)?
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,646

Post » Sun Oct 14, 2012 10:39 pm

bump
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,646

Post » Mon Oct 15, 2012 1:01 am

Here is a starting point:
http://dl.dropbox.com/u/5426011/examples14/word_highlight.capx
It finds the position of a word and then breaks the text into 3 separate instances (text prior to word, word, and text after). You can then change to color of the word independent of the rest of the text.

In it's current state it only works with one text line, and finds only one word to highlight.

Here's a list of what could be done to enhance the technique in roughly increasing difficulty:
* Make it work with multiple text objects.
* Make it highlight all occurrences of a word in a line.
* Make it able to highlight different words to different colors.
* Make it work with multi-line text.

I would take a look at the plugins to see if there are any that allow for displaying formatted html text as that would simplify it by replacing words like "green" with say "[_COLOR=#00ff00_]green[_/COLOR_]".R0J0hound2012-10-15 01:02:50
B
79
S
24
G
54
Posts: 4,755
Reputation: 40,773

Post » Tue Oct 16, 2012 3:23 am

[QUOTE=R0J0hound] Here is a starting point:
http://dl.dropbox.com/u/5426011/examples14/word_highlight.capx
It finds the position of a word and then breaks the text into 3 separate instances (text prior to word, word, and text after). You can then change to color of the word independent of the rest of the text.

In it's current state it only works with one text line, and finds only one word to highlight.

Here's a list of what could be done to enhance the technique in roughly increasing difficulty:
* Make it work with multiple text objects.
* Make it highlight all occurrences of a word in a line.
* Make it able to highlight different words to different colors.
* Make it work with multi-line text.

I would take a look at the plugins to see if there are any that allow for displaying formatted html text as that would simplify it by replacing words like "green" with say "[_COLOR=#00ff00_]green[_/COLOR_]".[/QUOTE]


R0J0hound delivers the best reply, thanks a lot. I tought Pode's HTML plugin there are html format can easily setup a color for a word, i'm not sure it can be dynamically done. I will try a test.
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,646


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests