Data Grid - set the bg colour of a text chunk

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 489
Joined: Thu Sep 04, 2008 6:23 am

Data Grid - set the bg colour of a text chunk

Post by jameshale » Tue Jul 17, 2012 9:43 am

I am using a Data Grid to list the results of a user search on text.
The results are returned using the FORM Data Grid with a field for each of the section heading (prefix_head), the line number of the found text (line_num) and the line of found text itself (the_results).

I wanted to enhance this by setting the background colour of the actual found text within the line of text returned.
To test this I simply set the background colour of a specific word and had a look.

The FillInData handler looks like this:

on FillInData pDataArray
set the text of field "prefix_head" of me to pDataArray["prefix_head"]
set the text of field "the_results" of me to pDataArray["the_results"]
set the backgroundcolor of word 5 of field "the_results" to 246,154,62
set the text of field "line_num" of me to pDataArray["line_num"]
end FillInData

This should set the background colour of the fifth word in each "the_results" field to an orange.

Well it does and it doesn't.

It seems to only set the colour on every fifth row.

So it works, but only once in five rows.

What am I missing?

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Data Grid - set the bg colour of a text chunk

Post by Klaus » Tue Jul 17, 2012 12:15 pm

Hi James,
jameshale wrote:What am I missing?
probably another "of me" :D

Try this:
...
set the backgroundcolor of word 5 of field "the_results" OF ME to 246,154,62
...

Best

Klaus

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 489
Joined: Thu Sep 04, 2008 6:23 am

Re: Data Grid - set the bg colour of a text chunk

Post by jameshale » Tue Jul 17, 2012 3:09 pm

yes.
I can see I need to not be so quick to ignore me in my coding :?

Thanks again.

James

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Data Grid - set the bg colour of a text chunk

Post by Klaus » Tue Jul 17, 2012 3:37 pm

Hi James,

I only knew cause i was hit by this some time ago, too 8)


Best

Klaus

Post Reply