Possible Actions bug with TDBSRichViewEdit

General TRichView support forum. Please post your questions here
Post Reply
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

Possible Actions bug with TDBSRichViewEdit

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

Post 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.
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

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

Post 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?
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

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

Post 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
pawnflakes
Posts: 49
Joined: Thu Jan 03, 2008 6:11 pm
Location: South-Africa

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