Page 1 of 1

Is this a bug or a feature ?

Posted: Thu Aug 11, 2011 5:10 pm
by kevin11
Helloe everybody,

Please pardon my ignorance....but.....

this works as expected :
put "abcdefgh" into field 1
set the textcolour of char 4 to 5 of field 1 to green

I get d and e in green, rest in white or whatever the default may be

but

put empty in field 1
put "abcdefgh" into field 1
set the textcolour of char 7 to 8 of field 1 to green
put "hello" after field 1

and I get "g" and "h" and "hello" all in green.

I would have thought that setting a textcolour over a range of characters would somehow switch the attribute on and then switch it off, but is seems that adding text to the field using after somehow overwrites the attribute switch-off ??? Documentation says using after should leave the present contents alone.

I can fix it by setting the colour of char 11 to white before adding the "hello" text, and that seems to work.

Is this a bug or is this expected ?

Thanks

Re: Is this a bug or a feature ?

Posted: Thu Aug 11, 2011 5:29 pm
by Klaus
Hi Kevin,

welcome to the forum! :D

I think this is correct behaviour, since "appended" text inherits all formats
(including color) from the character to its left.

Your workaround sounds OK!


Best

Klaus

Re: Is this a bug or a feature ?

Posted: Thu Aug 11, 2011 5:41 pm
by kevin11
Thanks Klaus. I suspected as much, but I am still curious as to how setting char 9 (when it doesn't exist yet) can then get inherited into appended text ? After the appending, the character on the left is still a green char 8 ????

Re: Is this a bug or a feature ?

Posted: Thu Aug 11, 2011 8:22 pm
by dunbarx
I think Klaus is correct. In a word processing document, like, say, MS Word (spits on floor) or any other, if you format the lastmost text, you will find that format continued if you then continue typing. Annoying sometimes, convenient others.

Craig Newman

Re: Is this a bug or a feature ?

Posted: Thu Aug 11, 2011 11:10 pm
by mwieder
It makes more sense once you realize that setting text colors is done with html. So if you look at the htmlText of the field contents you end up with something like

abcdef<font color="green">gh</font>

Then

Code: Select all

put "hello" after field 1
is actually a shortened version of

Code: Select all

put "hello" after the text of field 1
so you might expect to go after the "gh" rather than after the "<font>"

Whether you think of it as a bug or not probably depends on your point of view at the moment, but at least the workaround for getting non-colored text after colored text is easier than trying to do things the other way around.

Re: Is this a bug or a feature ?

Posted: Thu Aug 11, 2011 11:13 pm
by mwieder
oh... and welcome to the community...

Re: Is this a bug or a feature ?

Posted: Thu Aug 11, 2011 11:57 pm
by kevin11
Thank you for your welcomes !

However, with respect, there still seems to be a problem, even with your explanation taken into account. If chars 4 to 8 are set to green, and if I set char 9 to white before char 9 exists, then adding more text with "after" should, by your argument, overwrite the char 9 attributes, and leave me with green everywhere. This doesn't happen. The problem I am having is that it seems to be inconsistent, which often implies a bug.

My thinking is that when char 4 to 8 is set to green, and char 8 is the last character in the field, there is NO closing attribute applied, which is why extra text carries on picking up the green. Setting char 9 to white sets up the opening attribute, but the bug prevents the closing attribute. Extra text then carries on with the white attribute set.

So I agree with your explanation about the </font>, but I'm suggesting that it doesn't get applied after the very last character of a field. Almost as if a designer thought - don't need to close this attribute cos there's nothing coming after anyway.

Re: Is this a bug or a feature ?

Posted: Fri Aug 12, 2011 1:20 am
by mwieder
From the message box you can type something like

Code: Select all

put the htmlText of field "whatever"
and see what the actual html looks like.