Interesting backgroundcolor anomaly in text

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Interesting backgroundcolor anomaly in text

Post by kaveh1000 » Mon Sep 23, 2019 8:35 pm

Hi folks

I have just noticed something interesting. Please see the attached screenshot of two paragraphs in a field. The top para has had backgroundcolor to a number of characters, e.g.

Code: Select all

set the backgroundcolor of char x to y of fld 1 to pink
The lower para (actually a long line) has the following applies:

Code: Select all

set the backgroundcolor of line x of fld 1 to pink
so the whole para (or line) is colored.

Apart from the visual difference in that the background is not solid in the top para, I notice that in the second para when I select, the selection color (yellow) shows on top of the background color, but in the top case it does not.

I would be grateful for any insights as to the mechanism. is there a way to set bg color to a set of chars and still show selection color?
Attachments
bgcolor.png
Kaveh

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

Re: Interesting backgroundcolor anomaly in text

Post by dunbarx » Tue Sep 24, 2019 12:51 am

Did a test, and set the textHeight much larger that the textSoze. Also "fixed" the lineHeight.

So it seems that if you specify "lines" when delineating text, setting the backColor also fills in the spaces between those lines. Whereas if you specify characters, only the textSize's worth of vertical space is colored in each line.

This can be seen as a feature, I suppose.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Interesting backgroundcolor anomaly in text

Post by FourthWorld » Tue Sep 24, 2019 2:30 am

I think Craig nailed it. The char form used the older rendering method, while the line form uses the new paragraph-level features that apparently span the full block.

Whether the older form should be extended a few pixels vertically is an open question, but in short, very different rendering algos are in play here.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Interesting backgroundcolor anomaly in text

Post by dunbarx » Tue Sep 24, 2019 4:41 am

This is why Richard is Richard.

Craig

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Interesting backgroundcolor anomaly in text

Post by kaveh1000 » Tue Sep 24, 2019 7:59 am

Yes, a mine of information, and of course there is only one Craig. ;-)

Thanks for this. So this gives us the possibility of using the "newer" mechanism in combination with the old one. In screenshot I have set the bgcolor for the whole field, then bgcolor for line 3 (par 2), then word based coloring on top.

The only disadvantage with the the char or word based coloring is that the selection color does not show on top of the color...
Attachments
color.jpg
Kaveh

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10120
Joined: Fri Feb 19, 2010 10:17 am

Re: Interesting backgroundcolor anomaly in text

Post by richmond62 » Tue Sep 24, 2019 8:38 am

Sorry. late to the party. :D

BUT . . . I wonder if the 'problem' doesn't come down to the fact that,
in the original example, the 2 chunks of text are selected in different ways
(1: a range of chars, 2. text in a line):
-
Screenshot_20190924_103237.png
-
Screenshot taken on KDE Plasma
-
My stack sticks with method #1 for both chunks . . .
-
Stack removed as updated version below.
Last edited by richmond62 on Tue Sep 24, 2019 9:54 am, edited 1 time in total.

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Interesting backgroundcolor anomaly in text

Post by kaveh1000 » Tue Sep 24, 2019 8:52 am

Sorry, no latecomers. ;-)

Thanks for the demo stack Richmond. Yes, you are using method 1 and as Richard says method 2 uses a different mechanism. You will see that in method 1 selecting the text does not hide the backgroundcolor, and that is the problem in my case. i want the yellow to be on top of the red, as it is in the "new" method. But I am guessing that is deep inside the engine.
Kaveh

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10120
Joined: Fri Feb 19, 2010 10:17 am

Re: Interesting backgroundcolor anomaly in text

Post by richmond62 » Tue Sep 24, 2019 9:54 am

Um . . . (not knowing when to let something alone) . . .

backGroundColor

selectedText


what about foreGroundColor?
-
Screenshot_20190924_115123.png
-
Attachments
selectedColor.livecode.zip
Here's the stack.
(1.42 KiB) Downloaded 202 times

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Interesting backgroundcolor anomaly in text

Post by kaveh1000 » Tue Sep 24, 2019 10:03 am

yes, we can use foregroundcolor to color the text itself, but I want to have the behaviour of text selection in method 1 that is identical to that in method 2, with yellow in front of the red. To be honest not a huge deal...
Kaveh

Post Reply