Hi,
To edit an object you can use code likle this
procedure TWPRepTest.WPRichText1TextObjectMouseDown( Sender: TWPCustomRtfEdit; pobj: TWPTextObj; obj: TWPObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var s : string;begin if (pobj.ObjType=wpobjMergeField) and (Button=mbRight) then begin s := pobj.Name; If InputQuery('Field Properties', 'Name', s) then pobj.Name := s; end;end;
The problem is only that here the user has to exactly click in the start marker of the field.
With the following code the user can clck somewhere between the start and end markers of a field.
procedure TWPRepTest.WPRichText1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var pobj: TWPTextObj;
par: TParagraph;
posinpar: Integer;
s : string;
begin
if Button = mbRight then
begin
pobj := WPRichText1.CodeInsideOf(x, y, wpobjMergeField, par, posinpar);
if pobj <> nil then
begin
s := pobj.Name;
if InputQuery('Field Properties', 'Name', s) then
pobj.Name := s;
end;
end;
end;
Regards,
Julian