Highlight issue

General TRichView support forum. Please post your questions here
agent86
Posts: 59
Joined: Mon Jun 28, 2010 2:18 am
Location: San Francisco Bay Area, USA
Contact:

Highlight issue

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Where do you apply highlight?
agent86
Posts: 59
Joined: Mon Jun 28, 2010 2:18 am
Location: San Francisco Bay Area, USA
Contact:

RichEditor Demo...

Post 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]
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
agent86
Posts: 59
Joined: Mon Jun 28, 2010 2:18 am
Location: San Francisco Bay Area, USA
Contact:

That worked...

Post 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;
viperpix
Posts: 39
Joined: Sat Jan 15, 2011 9:38 am

Position Of Highlighted texts in RVE

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1) You can use the functions from RVLinear unit:
http://www.trichview.com/help/idh_rvlinear.html

2) For example?
viperpix
Posts: 39
Joined: Sat Jan 15, 2011 9:38 am

sample

Post by viperpix »

for example, in importing word documents, i dont wanna import (or paste) tables, or pictures.
thanks.
viperpix
Posts: 39
Joined: Sat Jan 15, 2011 9:38 am

and one more thing...

Post by viperpix »

how can i use RVLinear functions to get linear coordinates of background-highlighted texts in RVE?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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?
viperpix
Posts: 39
Joined: Sat Jan 15, 2011 9:38 am

hmmm..

Post 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 :)
viperpix
Posts: 39
Joined: Sat Jan 15, 2011 9:38 am

Problem!

Post by viperpix »

when i try to use rve.SelectAll , sometimes (many times) an exception: List index out of bounds (0) occurs! whats the problem?
viperpix
Posts: 39
Joined: Sat Jan 15, 2011 9:38 am

another problem..

Post by viperpix »

i have another problem too.. when the filename is just unicode characters, the rvc.importRV function can not import and returns False?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
viperpix
Posts: 39
Joined: Sat Jan 15, 2011 9:38 am

Re: Problem!

Post 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!
Post Reply