Line Colors: Every Other Line
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 52
- Joined: Sun Jan 20, 2008 7:06 am
Line Colors: Every Other Line
Does anybody know how to set every other line's background color differently? If you can help that'd be great.
Many thanks,
Christopher
Many thanks,
Christopher
Hi Christopher,
You can use a backgroundpattern for this. If your lines are all 14 pixels high, create a background pattern of 28 pixels hight, e.g. 14 pixels white and 14 pixels blue. If you set the backgroundpattern of a field to the ID of the image, you'll have alternately coloured lines.
Best,
Mark
You can use a backgroundpattern for this. If your lines are all 14 pixels high, create a background pattern of 28 pixels hight, e.g. 14 pixels white and 14 pixels blue. If you set the backgroundpattern of a field to the ID of the image, you'll have alternately coloured lines.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 52
- Joined: Sun Jan 20, 2008 7:06 am
Thanks
Thanks mark,
that's easy enough.
Many Thanks,
Christopher
that's easy enough.
Many Thanks,
Christopher
Just adding to this, is there any way to shade certain lines in a field.
Ive tried setting the backgroundcolor for the line, but it only puts the color behind the text and not right across.
What I would like to do is group certain lines of a table, say the first 4 items with a blue shade at the back, the next 6 with yellow etc, the number of lines would be variable, and the shade should be solid, just like when you highlight an entry (which I still need to be able to do!)
Any ideas?
Andy
Ive tried setting the backgroundcolor for the line, but it only puts the color behind the text and not right across.
What I would like to do is group certain lines of a table, say the first 4 items with a blue shade at the back, the next 6 with yellow etc, the number of lines would be variable, and the shade should be solid, just like when you highlight an entry (which I still need to be able to do!)
Any ideas?
Andy
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
In theory, you can do this by making the field transparent and place it on top of a group control which is a collection of rectangle graphics with the correct background color per line.
You can then have the underlying group scroll along with the field, by placing this script in the field:
Beware that groups can scroll no further than ~32000 pixels, so this is not going to work if you have a lot of lines.
Jan Schenkel.
You can then have the underlying group scroll along with the field, by placing this script in the field:
Code: Select all
on scrollbarDrag x
set the scroll of group "MyBackground" to the scroll of me
end scrollbarDrag
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
By looking for the same subject (different colors on different lines inside a field) I found this thread.
I would like to add my own solution.
Basically, within a table field, I want to "highlight" some lines with a specific background color, linked to the content of the table field, in order to ease the reading for user.
-table field, opaque false
-behind it, a set of small field, one per line of the table field
blending set at 30% for instance, opaque false
-then after the tricky part is to manage the "scroll" of the table field, to refresh the backgroundcolor (if needed) of the small fields.
I'm still working on it.
Something like that.
on scrollbarDrag
put the scroll of me div the textHeight of me into a
changeColorOfSmallFields (a)
end scrollbarDrag
on changeColorOfSmallFields para
repeat with c=1 to totalNumberOfLineOfTableField
put ("SmallField"&c) into SF
if line (c+para) of field "Table Field" contains KeywordToHighlight then
put "255,255,0" into myColor
set backgroundcolor of field SF to myColor
else
put "0,255,0" into myColor
set backgroundcolor of field SF to myColor
end if
end repeat
end changeColorOfSmallFields
I would like to add my own solution.
Basically, within a table field, I want to "highlight" some lines with a specific background color, linked to the content of the table field, in order to ease the reading for user.
-table field, opaque false
-behind it, a set of small field, one per line of the table field
blending set at 30% for instance, opaque false
-then after the tricky part is to manage the "scroll" of the table field, to refresh the backgroundcolor (if needed) of the small fields.
I'm still working on it.

Something like that.
on scrollbarDrag
put the scroll of me div the textHeight of me into a
changeColorOfSmallFields (a)
end scrollbarDrag
on changeColorOfSmallFields para
repeat with c=1 to totalNumberOfLineOfTableField
put ("SmallField"&c) into SF
if line (c+para) of field "Table Field" contains KeywordToHighlight then
put "255,255,0" into myColor
set backgroundcolor of field SF to myColor
else
put "0,255,0" into myColor
set backgroundcolor of field SF to myColor
end if
end repeat
end changeColorOfSmallFields
Regarding the way to "visually discriminate" some lines within a table field, there is another solution than the color background : HTML.
(idea found in a Eric Chatonet's stacks)
By simply putting a HTML text inside the table field, with a column with icons (or any other images).
(idea found in a Eric Chatonet's stacks)
By simply putting a HTML text inside the table field, with a column with icons (or any other images).
Code: Select all
constant kTab = " "
put "<p><b> <img src=" & quote & "200083" & quote & ">" & kTab &ktab&"THIS IS A TEST"&"</b></p>" & cr into tHtmlList
set the htmlText of fld "testhtml" to tHtmlList
Hi Bangkok,
What about the easy way?
Create a new field, set the listBehavior of the field to true, set the multipleHilited and the nonContiguousHilites of the field to true as well. Now just click and shift-click on the lines. You can set the toggleHilites of the field to true as well, which makes shift-clik unnecessary.
Best,
Mark
What about the easy way?
Create a new field, set the listBehavior of the field to true, set the multipleHilited and the nonContiguousHilites of the field to true as well. Now just click and shift-click on the lines. You can set the toggleHilites of the field to true as well, which makes shift-clik unnecessary.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Okay, but it gives you only 2 "colors" per line if I may say: non highlited and highlited , right ?Mark wrote: What about the easy way?
Create a new field, set the listBehavior of the field to true, set the multipleHilited and the nonContiguousHilites of the field to true as well. Now just click and shift-click on the lines. You can set the toggleHilites of the field to true as well, which makes shift-clik unnecessary.
Mark
Here is another way to "visually discriminate" some lines into a field.
-create an image, a colored bar, with some blend, of the width of your table field
-put a special character (like space) in the first column
-then we can use the propery imagesource
Trick found on :
http://mail.runrev.com/pipermail/use-re ... 14469.html
-create an image, a colored bar, with some blend, of the width of your table field
-put a special character (like space) in the first column
-then we can use the propery imagesource
Code: Select all
set the imagesource of char 1 of line 1 of fld "myField" to "myImage"
http://mail.runrev.com/pipermail/use-re ... 14469.html
Yes. It looks fine.Mark wrote:Bangkok, have you actually tried this with an image of the same width as the field?
Mark
Of course, I wouldn't use this solution.
But it was just to explore the thing.
I guess it's too heavy. I would rather go for the "fields behind" or the HTML solution (very elegant I think).

-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
You may have to tweak the 'margins' property of the field. The defautl value is '8' but this has as subtle side effect that the first line is actually tqwo pixels taller than the rest.
So try and set the 'margins' property (in the 'Text formatting' panel of the Inspector palette) to "8,6,8,8"
Hope this helped,
Jan Schenkel.
So try and set the 'margins' property (in the 'Text formatting' panel of the Inspector palette) to "8,6,8,8"
Hope this helped,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com