Page 1 of 1

Possible Actions bug with TDBSRichViewEdit

Posted: Sun Dec 07, 2008 8:15 pm
by pawnflakes
Hi

I'm using TDBSRichViewEdit with some actions. I'm having problems with some of the actions which i'm sure might be a bug. TDBSRichViewEdit is not working properly with the rvActionFontColor action. rvActionFontColor is working 100% when userinterface is rvacColorDialog but not when it is rvacAdvanced. I suspect that TDBSRichViewEdit looses focus and doesn't update properly when a color is selected. The same is also true for rvActionFontBackColor. I have also tried to manually change the color but with the same results. The caret jumps to the beginning of the line without changing any color at the current selection. My code is as follow:

with rvActionFontEx1 do
begin
UserInterface := false;
ValidProperties := [rvfimColor];
font.color:= acolor;
Execute;
UserInterface := true;
end;
DBRichViewEdit.SetFocus;
end;

Please investigate and reply whether it is indeed a bug?

Thank You

Posted: Thu Dec 11, 2008 11:29 am
by Sergey Tkachenko
Sorry, I cannot reproduce this problem.
I created a project with TDBSRichViewEdit and toolbar with 2 buttons.
One button is linked to TrvActionFontColor, another executes the code posted in your message.
Both work as expected.

I can imagine that you use some buttons that can be focused, instead of toolbar buttons. In this case it's not guaranteed that the actions will work with the specific control.
To fix this problem:
- use action.ExecuteTarget(DBSRichViewEdit1.RichViewEdit) instead of Execute
- assign DBSRichViewEdit1.RichViewEdit to action.Control or RVAControlPanel1.DefaultControl.

Posted: Thu Dec 11, 2008 7:07 pm
by pawnflakes
Thank you very much for your your help.

I'm using a TMS toolbar. The TMS toolbar button has it's own color drop-down menu. I have not assigned an action to the particular button. Instead I added the following code to the "OnSelectColor" event:

procedure TfrmMain.AdvOfficeColorSelector1SelectColor(Sender: TObject;
AColor: TColor);
begin
dbSRichViewEdit.SetFocus;
with rvActionFontEx1 do
begin
UserInterface := false;
ValidProperties := [rvfimColor];
font.color:= acolor;
ExecuteTarget(DBSRichViewEdit.RichViewEdit);
end;
dbSRichViewEdit.SetFocus;
end;

When choosing a color, the caret jumps to the beginning of the document and applies the color there. I have tried your suggestion above but i'm not sure what you meant by: assign DBSRichViewEdit1.RichViewEdit to action.Control or RVAControlPanel1.DefaultControl.

I have spend a couple of hours trying to figure this out, but to no avail. I'm sure this is just something small i'm missing but i'm on the verge of commiting suicide. :) Could you please give me an example on how to solve this problem.

Thank You

Posted: Thu Dec 11, 2008 7:22 pm
by Sergey Tkachenko
As I said, I cannot reproduce this problem. This code works ok for me when I assign it to toolbar buttons.
Can you create a simple project (without TMS components) reproducing this problem?

Posted: Tue Dec 16, 2008 4:16 pm
by pawnflakes
There was a strange problem in my code - I rewrote my application and changing the font color seems to work correctly now. I still have a problem changing the current text background color. I would like for this to be done manually without using the rvActionFontBackColor action since i'm using a 3rd party toolbar.

RVStyle.TextStyles[0].BackColor:= acolor;
rvactionfontbackcolor.Color:= acolor;
rvactionfontbackcolor.Executetarget(DBSRichViewEdit.RichViewEdit);

The problem with the above code is that it changes the entire text background and not the current selected text.

How could I achieve this?

Posted: Tue Dec 16, 2008 5:12 pm
by Sergey Tkachenko
Do not change properties of existing items in RVStyle.TextStyles collection. This change will affect all existing text formatted with this style.

Code: Select all

rvactionfontbackcolor.UserInterface := rvacNone
rvactionfontbackcolor.Color:= acolor; 
rvactionfontbackcolor.Executetarget(DBSRichViewEdit.RichViewEdit); 
rvactionfontbackcolor.UserInterface := rvacAdvanced; // restoring old value

Posted: Tue Dec 16, 2008 5:51 pm
by pawnflakes
Thank you very much for your help - I really appreciate your quick response. I've been very impressed with your component and service, and will be purchasing your component in the near future.