Page 1 of 1
Cannot understand colored lines in a field
Posted: Mon Mar 07, 2022 7:45 pm
by dunbarx
Here is a stack. Small and simple. I do not understand anything about it.
The button "colorLines" creates and names a new field "xxx". It then tries to select and color lines 2 and 3, waiting just a bit between those steps. This is an exercise to show the difference between the "selectedLines" and the "selectedChunk" in this process, derived from another recent thread.
I challenge anybody to tell me what is going on here, and especially to "clear" the field of all color. If you can, please tell me how.
Here is the handler in btn "colorLines".
Code: Select all
on mouseUp
if there is a fld "xxx" then delete fld "xxx"
wait 30
create fld "xxx"
set the rect of fld "xxx" to "50,50,200,200"
put "AAAA" & return & "BBBB" & return & "CCCC" & return & "DDDD" & return & "EEEE" into fld "xxx"
wait 40
select line 2 to 3 of fld "xxx"
set the backcolor of the selectedChunk to "255,215,255"
wait 40
set the backcolor of the selectedlines to "255,215,255"
wait 40
set the backcolor of fld "xxx" to "255,255,255"
end mouseUp
Craig
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 10:30 am
by bn
dunbarx wrote: ↑Mon Mar 07, 2022 7:45 pm
I challenge anybody to tell me what is going on here, and especially to "clear" the field of all color. If you can, please tell me how.
Craig
How about
Code: Select all
set the text of fld "xxx" to the text of fld "xxx"
?
Kind regards
Bernd
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 11:51 am
by richmond62

- Screen Shot 2022-03-08 at 12.49.27 PM.png (33.58 KiB) Viewed 5810 times
-
Someone has been having a 'purple patch', which while not being up
to the standard of Picasso's blue period does seem to throw a spanner in the works.
-
Once you set all those colours to empty this script in the 'clearColors' button
is pretty effective;
Code: Select all
on mouseUp
select line 1 to 10 of fld "xxx"
set the backcolor of the selectedChunk to empty
end mouseUp
Part of your problem seems to be
focus, so introduced a small textField
(originally and cunningly called "zz") and stuck an extra line of code
into your 'color'Lines' button:
Code: Select all
on mouseUp
if there is a fld "xxx" then delete fld "xxx"
wait 30
create fld "xxx"
set the rect of fld "xxx" to "50,50,200,200"
put "AAAA" & return & "BBBB" & return & "CCCC" & return & "DDDD" & return & "EEEE" into fld "xxx"
wait 40
select line 2 to 3 of fld "xxx"
set the backcolor of the selectedChunk to "255,215,255"
wait 40
set the backcolor of the selectedlines to "255,215,255"
wait 40
set the backcolor of fld "xxx" to empty
focus on fld "zz"
end mouseUp
And
Hot Damn . . .

Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 3:08 pm
by dunbarx
@Bernd.
Yes, setting the text does it. Thanks you. Clever, but cheating a bit, in that you are bombing the rubble, not resetting a property explicitly.
But I do not see how it relates to the oddly colored field. In other words, I do not see what field or text properties exist that are not accessible to me in the "ordinary" way.
@Richmond. Focusing on fld "zz" did affect just a little the colors in fld "zzz". It removed the purple in line 2, but still left the underlying pink block in lines 2-4.
Again, if we leave both your suggestions out, what property in fld "zzz" are we seeing? What is "pink"? Certainly not the backColor of certain lines in that field.
Craig
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 3:29 pm
by bn
dunbarx wrote: ↑Tue Mar 08, 2022 3:08 pm
@Bernd.
Yes, setting the text does it. Thanks you. Clever, but cheating a bit, in that you are bombing the rubble, not resetting a property explicitly.
But I do not see how it relates to the oddly colored field. In other words, I do not see what field or text properties exist that are not accessible to me in the "ordinary" way.
Craig
Code: Select all
set the backgroundColor of char 1 to -1 of field "xxx" to empty
and
Code: Select all
set the backgroundColor of line 1 to -1 of field "xxx" to empty
Those properties are distinct for char, line and field. The ones for the field are inherited, which is where the "effective propertyName" comes into play.
Kind regards
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 3:43 pm
by dunbarx
Bernd.
What property represents the color of lines 2 to 4 of that field? Those lines are definitely pink. I cannot clear them without your kludge, no offense.
Craig
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 4:10 pm
by bn
dunbarx wrote: ↑Tue Mar 08, 2022 3:43 pm
Bernd.
What property represents the color of lines 2 to 4 of that field? Those lines are definitely pink. I cannot clear them without your kludge, no offense.
Craig
EDIT
further studies are needed
Kind regards
Bernd
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 4:32 pm
by bn
dunbarx wrote: ↑Tue Mar 08, 2022 3:43 pm
Bernd.
What property represents the color of lines 2 to 4 of that field? Those lines are definitely pink. I cannot clear them without your kludge, no offense.
Craig
I edited my previous post because I changed your script otherwise.
this works for me
Code: Select all
on mouseUp
if there is a fld "xxx" then delete fld "xxx"
wait 30
create fld "xxx"
set the rect of fld "xxx" to "50,50,200,200"
put "AAAA" & return & "BBBB" & return & "CCCC" & return & "DDDD" & return & "EEEE" into fld "xxx"
wait 40
select line 2 to 3 of fld "xxx"
set the backcolor of the selectedChunk to "255,215,255"
wait 40
set the backcolor of (the selectedlines) to "255,215,255"
wait 40
set the backcolor of fld "xxx" to "255,255,255"
end mouseUp
so it seems that the brackets force a proper resolution of "the selectedlines"
Code: Select all
set the backcolor of (the selectedlines) to "255,215,255"
Kind regards
Bernd
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 4:34 pm
by dunbarx
Bernd.
set the backcolor of (the selectedlines) to "255,215,255"
That line always worked. That is what sets the color in the first place, just as setting the "selectedChunk" does. It does not matter if I include parentheses or not.
My question regards not being able to clear the pink block from the field. Your clever:
Code: Select all
set the text of fld "xxx" to the text of fld "xxx"
works fine, but is a kludge. I am asking how to clear that pink block by direct manipulation of a LiveCode property. The color is clearly there; a property of either the field or of those lines must correlate to that fact. What I thought ought to work:
Code: Select all
set the backcolor of fld "xxx" to "" -- or "255,255,255"
Does not.
Craig
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 4:51 pm
by bn
Craig,
I thought you were talking about the incorrect hiliting of line 4 in your code
This is your original code, it hilites line 2 to 4 instead of 2 to 3. That is cured by the brackets.
Code: Select all
on mouseUp
if there is a fld "xxx" then delete fld "xxx"
wait 30
create fld "xxx"
set the rect of fld "xxx" to "50,50,200,200"
put "AAAA" & return & "BBBB" & return & "CCCC" & return & "DDDD" & return & "EEEE" into fld "xxx"
wait 40
select line 2 to 3 of fld "xxx"
set the backcolor of the selectedChunk to "255,215,255"
wait 40
set the backcolor of the selectedlines to "255,215,255"
wait 40
set the backcolor of fld "xxx" to "255,255,255"
end mouseUp
If you want to get rid of the backColor of the selectedLines do
Code: Select all
set the backgroundColor of line 1 to -1 of field 1 to empty
That leaves you with the hilitedChars of the selectedChunk which you can get rid of by doing
Code: Select all
set the backColor of char 1 to -1 of field 1 to empty
The backgroundColor of the field is set to white in your case and does not affect the background color of eather char chunks or line chunks.
I hope that this time I answered to the right questions.
Kind regards
Bernd
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 5:45 pm
by dunbarx
Bernd.
Thanks for staying with me on this.
I tried all that stuff early on, being aware that the properties of the lines and the chars of a field are separate things. I used, in fooling around:
Code: Select all
set the backcolor line 1 to 5 of fld "xxx" to ""
set the backcolor char 1 to 500 of fld "xxx" to ""
But adding both those lines left me with a different situation. Lines 2 and 3 remain colored.
And it makes a difference, no surprise, that setting the backColor to empty is different than setting it to "255,255,255".
But I am still left with color in my field, and no LiveCode property I can find to account for that fact.
Craig
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 5:49 pm
by bn
dunbarx wrote: ↑Tue Mar 08, 2022 5:45 pm
But I am still left with color in my field, and no LiveCode property I can find to account for that fact.
Craig
What exactly is colored after you clear lines and chars of backgroundColor?
For me it is only the textColor or foreColor that is kind of blue.
Kind regards
Bernd
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 6:05 pm
by dunbarx
I suspect it might be something inside my machine. It looks like this:
Craig
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 6:24 pm
by bn
dunbarx wrote: ↑Tue Mar 08, 2022 6:05 pm
I suspect it might be something inside my machine. It looks like this:
Screen Shot 2022-03-08 at 12.02.54 PM.zip
Craig
The ghost in the machine is the selection.
Make a button for your stack with the script
Code: Select all
on mouseUp
set the backgroundcolor of char 1 to -1 of field "xxx" to empty
set the backgroundColor of line 1 to -1 of field "xxx" to empty
select empty
end mouseUp
and it will clear all colorization.
Kind regards
Bernd
Re: Cannot understand colored lines in a field
Posted: Tue Mar 08, 2022 8:29 pm
by dunbarx
Bernd.
OK, this is all you need:
Code: Select all
set the backcolor of line 1 to 5 of fld "xxx" to "255,255,255" -- or empty
wait 44
select empty
You simply have to lose focus of the field. Richmond mentioned that as well. I never thought I needed to have to do that. I wish i had clicked on an another stack during all the travail. It is odd to me that clicking on an empty part of the actual card does not do the same thing.
OK, another little trick to try to remember. Why the setting of the backColor doesn't just work on its own is something I intend to ignore.
Thanks again.
Craig