Page 1 of 1
apply a determined color to my selected text
Posted: Sun Apr 08, 2012 7:22 pm
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
Posted: Mon Apr 09, 2012 5:44 pm
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;
Posted: Sun Apr 15, 2012 10:33 pm
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?
Posted: Mon Apr 16, 2012 6:44 am
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.
Posted: Mon Apr 16, 2012 6:46 am
by Sergey Tkachenko
A correction to your code:
use
rvActionFontColor1.ExecuteTarget(Editor1.ActiveEditor);
instead of
rvActionFontColor1.ExecuteTarget(Editor1.RichViewEdit);
Posted: Mon Apr 16, 2012 11:19 am
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
Posted: Tue Apr 17, 2012 1:03 am
by alexandreq
Sergey,
Do you have any prevision for the next update where you will include this fix?
Posted: Tue Apr 17, 2012 10:50 am
by Sergey Tkachenko
I have sent a changed file to you by email.
Posted: Tue Apr 17, 2012 11:05 am
by alexandreq
Hello Sergey
I haven't received it yet.
have you sent it to alexandrenicolas at bol dot com dot br ?
Posted: Tue Apr 17, 2012 11:12 am
by alexandreq
I got it
thanks
Posted: Tue Apr 17, 2012 11:23 am
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