apply a determined color to my selected text

General TRichView support forum. Please post your questions here
Post Reply
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

apply a determined color to my selected text

Post by alexandreq »

Hello Sergey,

I have a function that find a word in all my text, each word found, the function selects it and (now is the doubt)

When I select a found word in my text, I want to change the color of the font, or the background text color to yellow, for example.

How can I do this?

Actually to change the color of my selected text I use the action rvActionFontColor1.

thanks
Alexandre
Sergey Tkachenko
Site Admin
Posts: 17561
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The coloring actions can apply the specified colors without displaying a color picker:

Code: Select all

rvActionFontColor1.UserInterface := rvacNone;
rvActionFontColor1.Color := clRed;
rvActionFontColor1.ExecuteTarget(RichViewEdit1);
rvActionFontColor1.UserInterface := rvacAdvanced;
For the background color, use TrvActionFontBackColor.

If you want to apply both:

Code: Select all

rvActionFontColor1.UserInterface := rvacNone;
rvActionFontBackColor1.UserInterface := rvacNone;

rvActionFontColor1.Color := clRed;
rvActionFontBackColor1.Color := clYellow;

RichViewEdit1.TopLevelEditor.BeginUndoGroup(rvutStyleNo);
RichViewEdit1.TopLevelEditor.SetUndoGroupMode(True);
rvActionFontColor1.ExecuteTarget(RichViewEdit1);
rvActionFontBackColor1.ExecuteTarget(RichViewEdit1);
RichViewEdit1.TopLevelEditor.SetUndoGroupMode(False);

rvActionFontColor1.UserInterface := rvacAdvanced;
rvActionFontBackColor1.UserInterface := rvacAdvanced;
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

Hello Sergey,

I don't know why but when I give a double click in a word and try to apply the color font to my selected word, it is not working.

Take a look at my code:

Code: Select all

procedure TFEDITORTEXTO.Editor1DblClick(Sender: TObject);
begin
  if rvActionItemProperties1.Enabled then
     rvActionItemProperties1.ExecuteTarget((Sender as TSRichViewEdit).ActiveEditor);

  rvActionFontColor1.UserInterface := rvacNone;
  rvActionFontColor1.Color := clRed;
  rvActionFontColor1.ExecuteTarget(Editor1.RichViewEdit);
  rvActionFontColor1.UserInterface := rvacAdvanced;
end;

In my editor, Is there a option that the user must select a word and apply an color, this is possible in RichEdit, why not is possible in DBSRichViewEdit? Something that I forgot to insert into my code?
Sergey Tkachenko
Site Admin
Posts: 17561
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Well, there is a problem in TSRichViewEdit: first, it calls dblclick events; only after that, it selects the doubleclicked word.
It will fixed in the next update.
Sergey Tkachenko
Site Admin
Posts: 17561
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

A correction to your code:
use
rvActionFontColor1.ExecuteTarget(Editor1.ActiveEditor);
instead of
rvActionFontColor1.ExecuteTarget(Editor1.RichViewEdit);
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

Hello Sergey,

Yeah, due to that problem that after calling the doubleclick event, it selects the word, I can't apply the font color.

I made the change you told me to do and also nothing was did. But we both know that this problem is due to that.

I will wait the fixed version

This fix will help me with another question too.

thanks
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

Sergey,

Do you have any prevision for the next update where you will include this fix?
Sergey Tkachenko
Site Admin
Posts: 17561
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I have sent a changed file to you by email.
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

Hello Sergey

I haven't received it yet.

have you sent it to alexandrenicolas at bol dot com dot br ?
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

I got it :)

thanks
alexandreq
Posts: 184
Joined: Wed Jan 18, 2012 6:22 pm

Post by alexandreq »

Sergey,

Now this function GetSelText is also working fine :))

This was an error that I had times ago

http://www.trichview.com/forums/viewtopic.php?t=5106
Post Reply