Page 1 of 1
Richviewedit Font resets after clicking at the cursor position
Posted: Wed Dec 21, 2022 11:18 am
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 (24.22 KiB) Viewed 10136 times
Nevertheless, if I click at the current cursor position, the font resets.
- ChangedFontAfterSentence.png (24.71 KiB) Viewed 10136 times
- ChangedFontAfterSentenceClick.png (32.85 KiB) Viewed 10136 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?
Re: Richviewedit Font resets after clicking at the cursor position
Posted: Wed Dec 21, 2022 11:46 am
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 (26.8 KiB) Viewed 10131 times
Selection starts from the bottom.
- FontSelectionDemoStartedBottom.png (26.21 KiB) Viewed 10131 times
The font combo box is empty if I have the same situation in MS Word.
- FontSelectionWord.png (9.44 KiB) Viewed 10131 times
Is there anything I can do to get the same behavior as in MS Word?
Re: Richviewedit Font resets after clicking at the cursor position
Posted: Wed Dec 21, 2022 11:51 am
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)
Re: Richviewedit Font resets after clicking at the cursor position
Posted: Wed Dec 21, 2022 12:08 pm
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)
Re: Richviewedit Font resets after clicking at the cursor position
Posted: Wed Dec 21, 2022 12:42 pm
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.
Re: Richviewedit Font resets after clicking at the cursor position
Posted: Wed Dec 21, 2022 1:12 pm
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.
Re: Richviewedit Font resets after clicking at the cursor position
Posted: Wed Dec 21, 2022 1:29 pm
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,