Problem applying text style to individual words

General TRichView support forum. Please post your questions here
Post Reply
jimbr32
Posts: 20
Joined: Thu Nov 09, 2006 10:01 pm

Problem applying text style to individual words

Post by jimbr32 »

I'm using fixed textstyles with RichViewEdit, and I need to change the text styles of individual words. I'm seeing a problem where if I change the text style of the first word of a line, the style change can cause the last word of the previous line to drop to the current line.

For example, say I have 6 words, arranged like this:

Word1 Word2 Word3 Word4
Word5 Word6

If I select Word5 and apply a style change, the text shifts like this after the style is applied:

Word1 Word2 Word3
Word4 Word5 Word6

The problem seems to depend on how close Word4 is to the right margin.

I can cause the problem using this code:

Code: Select all

With RVStyle1 do
begin
  TextStyles[1].Assign(TextStyles[0]);
  TextStyles[1].Color := clBlue;
end;
ApplyTextStyle(1);
I'm seeing the same thing in the Editor 2 demo if I change the text color of the first word of a line, like above.

Is there a way to prevent this ?

Thanks
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Can you give me step-by-step instructions how to reproduce this problem?
jimbr32
Posts: 20
Joined: Thu Nov 09, 2006 10:01 pm

Post by jimbr32 »

To see this happen in demo Editor 2 (DelphiUnicode\Editors\Editor 2) do this:

1. Enter some text into the editor, enough for the text to wrap to a second line.
2. Set the width of the editor window so that the right margin is very close to the last word on the first line.
3. Select the first word on the second line.
4. Click the Text Color button and change the color of the selected word.

After the style is changed, the last word on the first line drops to the second line.

If it helps there is a zip with some screenshots at https://www.dropbox.com/s/45ogluiipquel ... s.zip?dl=0

The screenshots show how the text is rearranged when I change the text color of the first word, second line to red.

This is the same thing I'm seeing when I use the ApplyTextSytle code in the original post.
jimbr32
Posts: 20
Joined: Thu Nov 09, 2006 10:01 pm

Post by jimbr32 »

Hi Sergey

Just wanted to check if you were able to duplicate this. Are you able to tell if I'm doing something wrong, or do you know of any workaround available to prevent the word shifting?

I understand that some text style changes may cause this, but if possible I'd like to prevent words from moving if the only attribute I'm changing is color, and possibly underline.

Thanks
Jim
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, I found the reason for this problem, it will be fixed in the next update.
jimbr32
Posts: 20
Joined: Thu Nov 09, 2006 10:01 pm

Post by jimbr32 »

Great! Thank you Sergey
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Fixed in v16.6 (available for registered users)
Post Reply