Custom Actions

General TRichView support forum. Please post your questions here
Post Reply
wvd_vegt
Posts: 83
Joined: Tue Aug 30, 2005 7:39 am

Custom Actions

Post by wvd_vegt »

Is there an action available that allows you to assign an event handler that gets the TRichViewEdit instance passed? If not, what should i subclass to create such action?

I'm looking for buttons that will nicely enable and disable when a TRichViewEdit is active and peform some custom operations like updating the preview inside the webbrowser.
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Any action can do that.
You need to override methods:

Code: Select all

function TrvAction.HandlesTarget(Target: TObject): Boolean;
begin
  Result := Target is TCustomRichViewEdit;
end;

// updating actions properties
procedure TrvAction.UpdateTarget(Target: TObject);
begin
  // Target is a TCustomRichViewEdit
  // but it may be cell inplace editor
  // To get the real editor, use 
  // TCustomRichViewEdit(Target).RootEditor;
  
  // Here you can update the action's properties
  // such as Enabled or Checked, depending
  // on the RichViewEdit state and other
  // circumstances
end;

// executing 
procedure TrvAction.ExecuteTarget(Target: TObject);
begin
  // Target is a TCustomRichViewEdit
  // but it may be cell inplace editor
  // To get the real editor, use 
  // TCustomRichViewEdit(Target).RootEditor;

  // Execute the operation
end;
For examples, see RichViewActions, RichViewActions.pas.
Guest

Requirments

Post by Guest »

Is there an action available that allows you to assign an event handler that gets the TRichViewEdit instance passed? If not, what should i subclass to create such action?
What do i need to get this to work? :wink:
wvd_vegt
Posts: 83
Joined: Tue Aug 30, 2005 7:39 am

Post by wvd_vegt »

Hi,

I PM'ed a simple version to Sergey Tkachenko to see wether he likes it and want to add it to the RichView Actions.
Post Reply