I noticed that when I used the OnHyperlinkForm event in the rvActionInsertHyperlink1 action the dialog never appeared. In checking the code it bypasses the dialog regardless of the value of Proceed.
I made the following change to the code, which works. Was this fix needed or did I misunderstand the purpose of the event?
function TrvActionInsertHyperlink.DoShowForm(InsertNew: Boolean; var Text,
Target: String): Boolean;
var frm: TfrmRVHyp;
begin
{ if Assigned(FOnHyperlinkForm) then begin
Result := True;
FOnHyperlinkForm(Self, InsertNew, Text, Target, Result);
end
else begin }
// modification to allow OnHyperlinkForm event to be called and then
// still show the form
if Assigned(FOnHyperlinkForm) then begin
Result := True;
FOnHyperlinkForm(Self, InsertNew, Text, Target, Result);
end;
if Result then begin
// end of modification
frm := TfrmRVHyp.Create(Application);
...
RichViewActions and OnHyperlinkForm
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 27
- Joined: Mon Aug 29, 2005 7:08 pm
Sergey,
Okay, I understand. Since I do not like to change vendor source code, maybe you could give me an alternative.
The reason why I want to expose this event is to retain the current font when a hyperlink is edited. Assigning the colors works fine, since the default form allows the user to change the font color and font hover color. However, the text is always underlined after editing.
I can set the Style property to [] in the action, but then it removes underlines if I want it.
In order to retain the current style and colors, I use the event like this:
procedure TdmRichViewMod.rvActionInsertHyperlink1HyperlinkForm(
Sender: TObject; InsertNew: Boolean; var Text, Target: String;
var Proceed: Boolean);
begin
with CurRichViewEdit do begin
rvActionInsertHyperlink1.Style := Style.TextStyles[CurItemStyle].Style;
rvActionInsertHyperlink1.Color := Style.TextStyles[CurItemStyle].Color;
rvActionInsertHyperlink1.HoverColor :=
Style.TextStyles[CurItemStyle].HoverColor;
end;
Proceed := True;
end;
This works fine, as long as I change the code in the action so it still shows the default form.
Can you suggest another way to handle this, short of creating my own form (which, I guess, would not be that difficult)?
Okay, I understand. Since I do not like to change vendor source code, maybe you could give me an alternative.
The reason why I want to expose this event is to retain the current font when a hyperlink is edited. Assigning the colors works fine, since the default form allows the user to change the font color and font hover color. However, the text is always underlined after editing.
I can set the Style property to [] in the action, but then it removes underlines if I want it.
In order to retain the current style and colors, I use the event like this:
procedure TdmRichViewMod.rvActionInsertHyperlink1HyperlinkForm(
Sender: TObject; InsertNew: Boolean; var Text, Target: String;
var Proceed: Boolean);
begin
with CurRichViewEdit do begin
rvActionInsertHyperlink1.Style := Style.TextStyles[CurItemStyle].Style;
rvActionInsertHyperlink1.Color := Style.TextStyles[CurItemStyle].Color;
rvActionInsertHyperlink1.HoverColor :=
Style.TextStyles[CurItemStyle].HoverColor;
end;
Proceed := True;
end;
This works fine, as long as I change the code in the action so it still shows the default form.
Can you suggest another way to handle this, short of creating my own form (which, I guess, would not be that difficult)?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You can use OnExecute event.
In this event, add your code, then use this code to run the default action method:
In this event, add your code, then use this code to run the default action method:
Code: Select all
rvActionInsertHyperlink1.OnExecute := nil;
try
rvActionInsertHyperlink1.ExecuteTarget(RichViewEdit1);
finally
rvActionInsertHyperlink1.OnExecute := rvActionInsertHyperlink1Execute;
end;