Page 1 of 2

Highlight issue

Posted: Tue Nov 23, 2010 9:45 pm
by agent86
When I highlight text and select a highlight color and hit [OK], the text still shows the dark blue highlight. How can I get it to reveal the selected highlight color like MS Word works?

Posted: Wed Nov 24, 2010 4:15 pm
by Sergey Tkachenko
Where do you apply highlight?

RichEditor Demo...

Posted: Wed Nov 24, 2010 4:50 pm
by agent86
I am using the RichEditor Demo.

I should make one thing clear. The highlighting takes place but it is not visible until I move the cursor. Then the highlight is visible. With MS Word when you select the highlight color the cursor moves to the front of the highlighted word annd the highlight color is immediately visible.

So how can I tell the cursor to move to the front of the highlighted word revealing the new highlight color?

[/img]

Posted: Wed Nov 24, 2010 6:26 pm
by Sergey Tkachenko
In TRichView, the color of selection does not depend on the color of selected text.
If you want to view the result of the color change immediately, you can remove the selection after applying color.
For example, for the background color, you can add to the end of TForm1.btnFontBackColorClick the following code:

Code: Select all

  with rve.TopLevelEditor do
    SetSelectionBounds(CurItemNo, OffsetInCurItem, CurItemNo, OffsetInCurItem);
  rve.TopLevelEditor.Invalidate;

That worked...

Posted: Sun Nov 28, 2010 6:22 am
by agent86
Here is the application of your suggestion. Thanks...


procedure TFindingEntry.TextHighlightColor ;
begin
// if no highlight display color selection. if color, display messagebox
cd.Color := rvs.TextStyles[rve.CurTextStyleNo].BackColor;
if cd.Color = clNone then
begin
cd.Color := rvs.TextStyles[rve.CurTextStyleNo].BackColor;
if cd.Color=clNone then
cd.Color := clWhite;
if not cd.Execute then
exit;
end
else
begin // display messagebox

case Application.MessageBox('Clear the selected text highlight color? '#13+
'(YES - clear highlight; NO - choose color)',
'Text Background', MB_YESNOCANCEL or MB_ICONQUESTION) of
IDYES:
cd.Color := clNone;
IDNO:
begin
cd.Color := rvs.TextStyles[rve.CurTextStyleNo].BackColor;
if cd.Color=clNone then
cd.Color := clWhite;
if not cd.Execute then
exit;
end;
IDCANCEL:
exit;
end;
end ;
rve.ApplyStyleConversion(TEXT_BACKCOLOR);

// test

with rve.TopLevelEditor do
SetSelectionBounds(CurItemNo, OffsetInCurItem, CurItemNo, OffsetInCurItem);
rve.TopLevelEditor.Invalidate;




end;

Position Of Highlighted texts in RVE

Posted: Sat Feb 05, 2011 10:20 am
by viperpix
Hi,
i'm about to find the character Position of Highlighted texts in RVE, but im worndering how can i achieve that, and also i dont know the GetSelectionBounds function works with offset, cuz everytime it just returns the length of selected text +1 instead of strartOffset and endOffset (both are the same)!

and one more question :D
How can i find the type of items in RVE and filter some types and preventing them to be placed in RVE ?

THANK YOU.

Posted: Sun Feb 06, 2011 2:19 pm
by Sergey Tkachenko
1) You can use the functions from RVLinear unit:
http://www.trichview.com/help/idh_rvlinear.html

2) For example?

sample

Posted: Mon Feb 07, 2011 5:28 am
by viperpix
for example, in importing word documents, i dont wanna import (or paste) tables, or pictures.
thanks.

and one more thing...

Posted: Mon Feb 07, 2011 6:10 am
by viperpix
how can i use RVLinear functions to get linear coordinates of background-highlighted texts in RVE?

Posted: Mon Feb 07, 2011 7:01 pm
by Sergey Tkachenko
1) For RTF import (as well as for all formats imported via RTF using TRVOfficeConverter), TRichView.RTFReadProperties has the following properties:
- IgnoreBookmarks;
- IgnoreNotes;
- IgnorePictures;
- IgnoreSequences;
- IgnoreTables;
- SkipHiddenText.

2) Do you mean selected text? What do you want to do with these coordinates later?

hmmm..

Posted: Tue Feb 08, 2011 5:31 am
by viperpix
1) tnx for this solution, but what about Pasting Pictures for example? how can i ban the picture paste?

2) No, i mean a text with red background for example. if i knew how to get the FontInfo.BackColor of each item, this would be solved!
i want to export only the back-colored sections of the text for a reason!

tnx :)

Problem!

Posted: Tue Feb 08, 2011 6:19 am
by viperpix
when i try to use rve.SelectAll , sometimes (many times) an exception: List index out of bounds (0) occurs! whats the problem?

another problem..

Posted: Tue Feb 08, 2011 6:47 am
by viperpix
i have another problem too.. when the filename is just unicode characters, the rvc.importRV function can not import and returns False?

Posted: Tue Feb 08, 2011 7:29 am
by Sergey Tkachenko
1) You can allow pasting only RVF, RTF and plain text:

Code: Select all

procedure TForm3.RichViewEdit1Paste(Sender: TCustomRichViewEdit;
  var DoDefault: Boolean);
begin
  if Sender.CanPasteRVF then
    Sender.PasteRVF
  else if Sender.CanPasteRTF then
    Sender.PasteRTF
  else if Clipboard.HasFormat(CF_TEXT) then
    Sender.PasteText;
  DoDefault := True;
end;
Unfortunately, there are no ways to exclude pictures or tables when inserting RVF (RichView Format), so you may exclude it as well (well, there is a way: pasting in a hidden TRichViewEdit, removing pictures and tables in it, saving this hidden RichViewEdit using SaveRVFToStream, then inserting in the main editor using InsertRVFFromStreamEd).
Additionally, pictures or tables can appear as a result of drag&drop. You can exclude formats from AcceptDragDropFormats property.

Re: Problem!

Posted: Tue Feb 08, 2011 7:34 am
by viperpix
viperpix wrote:when i try to use rve.SelectAll , sometimes (many times) an exception: List index out of bounds (0) occurs! whats the problem?
its gonna happen almost after importing HTML files! something like this:

rvc.importRV(od.FileName, rve, 0);
rve.SelectAll;

if i import anythin one time, the next time which i want to import a HTML file out of bounds error bug me!