foregroundColor of lines of a field?

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
Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

foregroundColor of lines of a field?

Post by Zax » Mon Apr 18, 2016 4:01 pm

Hello,

I tried to set different foregroundColor of different lines of fld but only the last was well coloured.
I used this sample script :

Code: Select all

put "Blue,Black,Red" into colours
put "" into fld "MyField"
repeat with i = 1 to (the number of items in colours)
	get item i of colours
	put it into line i of fld "MyField"
	set the foregroundColor of line i of fld "MyField" to it
end repeat
Of course, I could do a second pass, in order to apply colours. Is it the only way to do what I want or I miss something?

Second pass:

Code: Select all

repeat with i = l to (the number of line in fld "MyField")
	set the foregroundColor of line l of fld "MyField" to (line l of fld "MyField")
end repeat
Thank you for you help.


Another thing, when I try to paste some text from a LC application in a text document, it only works if I didn't QUIT my LC application. Is it normal?
I'm using:

Code: Select all

set the clipboardData["text"] to "MyTest"

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: foregroundColor of lines of a field?

Post by dunbarx » Mon Apr 18, 2016 5:04 pm

HI.

Your first handler works fine for me in v. 6.7. As it should. What are you seeing? No foreground color at all?

As for the clipboard, I have seen this intermittently. Sometimes I can reproduce it, sometimes not. Anyone else see this?

Craig Newman

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: foregroundColor of lines of a field?

Post by Zax » Wed Apr 20, 2016 10:07 am

dunbarx wrote:Your first handler works fine for me in v. 6.7. As it should. What are you seeing? No foreground color at all?
For me, only the last line is coloured.

It seems the command:

Code: Select all

put it into line i of fld "MyField"
refreshes the field and so resets colours.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: foregroundColor of lines of a field?

Post by dunbarx » Wed Apr 20, 2016 3:49 pm

Hi.

This is very odd. Please forward your stack, the one where only the last line is colored, to QCC. Or post it here first, so I can test it. But what version of LC are you working in?

Craig

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

Re: foregroundColor of lines of a field?

Post by Klaus » Wed Apr 20, 2016 4:00 pm

put "Blue,Black,Red" into colours
put "" into fld "MyField"
repeat with i = 1 to (the number of items in colours)
get item i of colours
put it into line i of fld "MyField"
set the foregroundColor of line i of fld "MyField" to it
end repeat
Your script works as exspected in LC 8.0 RC1!

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: foregroundColor of lines of a field?

Post by Zax » Thu Apr 21, 2016 9:53 am

This is a sample stack with the script, and a screnne capture of what happens when I run the script with LC 7.0.0
TestColours.livecode.zip
(1.39 KiB) Downloaded 209 times
TestColours_screen.jpg
TestColours_screen.jpg (24.75 KiB) Viewed 4659 times

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

Re: foregroundColor of lines of a field?

Post by Klaus » Thu Apr 21, 2016 11:49 am

The stack and script also work as exspected in LC 7.1.3!

However I would highly recommend to NOT use IT more often that neccessary,
since IT changes when you least exspect IT! :D

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: foregroundColor of lines of a field?

Post by dunbarx » Thu Apr 21, 2016 3:33 pm

Might you be using v.8? If neither Klaus nor I can duplicate your problem in 6 or 7, I would suspect the version...

Craig

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: foregroundColor of lines of a field?

Post by Zax » Fri Apr 22, 2016 8:20 am

Your conclusion seems right. Maybe there is a bug with the 7.0.0 version.

Anyway, thank you.

Post Reply