Richviewedit Font resets after clicking at the cursor position

General TRichView support forum. Please post your questions here
Post Reply
tomr
Posts: 22
Joined: Wed Dec 09, 2020 9:36 am

Richviewedit Font resets after clicking at the cursor position

Post by tomr »

Hello Richview Support,
While working with Richviewedits I found some dissonances regarding fonts.
If I change the font at the end of a sentence and start typing immediately, everything is fine, and I can start writing with the selected font.
ChangedFontAfterTyping.png
ChangedFontAfterTyping.png (24.22 KiB) Viewed 10337 times
Nevertheless, if I click at the current cursor position, the font resets.
ChangedFontAfterSentence.png
ChangedFontAfterSentence.png (24.71 KiB) Viewed 10337 times
ChangedFontAfterSentenceClick.png
ChangedFontAfterSentenceClick.png (32.85 KiB) Viewed 10337 times
In other applications like MS Word, it does not reset.
Is there anything I can do to have the same behavior as in MS Word?
tomr
Posts: 22
Joined: Wed Dec 09, 2020 9:36 am

Re: Richviewedit Font resets after clicking at the cursor position

Post by tomr »

While testing, I found another dissonance regarding fonts from selected paragraphs.
Situation:
I have a paragraph that contains two or more different fonts. I select the complete section. Now the combo box for the font is filled with the last font.
Selection starts from the top.
FontSelectionDemoStartedTop.png
FontSelectionDemoStartedTop.png (26.8 KiB) Viewed 10332 times
Selection starts from the bottom.
FontSelectionDemoStartedBottom.png
FontSelectionDemoStartedBottom.png (26.21 KiB) Viewed 10332 times
The font combo box is empty if I have the same situation in MS Word.
FontSelectionWord.png
FontSelectionWord.png (9.44 KiB) Viewed 10332 times
Is there anything I can do to get the same behavior as in MS Word?
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Richviewedit Font resets after clicking at the cursor position

Post by standay »

tomr,

Just FYI, I tried this in Word 2013, LibreOffice 7.4 and online Word and they all "reset" this way for me. I didn't always see the font name change in the font combo box immediately but they did "reset" as I started to type.

Stan (I'm not with richview "support," just saw your post and tried it myself)
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Richviewedit Font resets after clicking at the cursor position

Post by standay »

tomr,

I tried your selection thing with different fonts in both the rich edit and scale rich edit demos. And both of those show the font name of the selection point text as you are seeing. I think all that is is the way Sergey coded his demos. In my current app I coded mine to display the word [Mutliple] (in brackets) if mutible fonts are in the selection. I did this in the rve CurTextStyleChanged procedure (I just use a regular richview edit in my app).

Code: Select all

  rv.GetSelectionBounds(FStart, FSOff, FEnd, FEoff, true);
    fi := rv.Style.TextStyles[rv.GetItemStyle(FStart)];
  
    for i := FStart to FEnd do
    begin
      fi2 := rv.Style.TextStyles[rv.GetItemStyle(i)];
      if fi.FontName <> fi2.FontName then
      begin
        SRDCvsRVEFont.Caption := '[Multiple]'; 
        //This could be set to SRDCvsRVEFont.Caption := '' to mimic Word behavior
        break;
      end;
    end;
Same thing for the font size combo:

Code: Select all

    for i := FStart to FEnd do
    begin
      fi2 := rv.Style.TextStyles[rv.GetItemStyle(i)];
      if fi.Size <> fi2.Size then
      begin
        //Reset Combo
        cmbFontSize.Text := '';
        break;
      end;
    end;
So, I think you'd just need to write some code to do that in your app.

Stan (I'm not with richview "support," just saw your post and tried it myself)
tomr
Posts: 22
Joined: Wed Dec 09, 2020 9:36 am

Re: Richviewedit Font resets after clicking at the cursor position

Post by tomr »

Hello standay,
thank you for your reply.
I have got Word 2016 installed and for me, it works as described above.
Implementing the CurTextStyleChanged Event is a Good Idea, I will try it.
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Richviewedit Font resets after clicking at the cursor position

Post by Sergey Tkachenko »

1. Yes, if the user changes font, types nothing, then clicks in the editor, the current text style is reset to the font at the position of the caret. I did not think that this is a problem because usually users change font to type content. And the comboboxes should focus the editor after selection, so clicking is not needed.

2. Yes, combo boxes of RichViewActions (TRVFontComboBox, TRVFontSizeComboBox, TRVStyleTemplateComboBox), unlike controls in RichViewActions dialogs, do not analyze the whole selection, they reflect the content at the caret position.
If you want, I can add an option in one of future updates.
tomr
Posts: 22
Joined: Wed Dec 09, 2020 9:36 am

Re: Richviewedit Font resets after clicking at the cursor position

Post by tomr »

Hello Sergey,
Thank you for your fast reply and additional Information. :)
1. Ah ok, that makes sense. You are right, usually, extra clicking is unnecessary.
2. I would appreciate it if you add such an option in the future,
Post Reply