Adding actions

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Adding actions

Post by toolwiz »

Sorry, I'm not very familiar with using actions.

How can I add an action with a toolbar button and that appears in the right-click menu in the SRV editor when the user has selected text, like with Copy, Paste, Del, etc?

------------------------------------------------

The readme.rvf file says:

Preparing for the Actions

1. Right-click RichViewEdit in Delphi/C++Builder, choose Settings in the context menu, select “Allow adding styles dynamically”, "Tag store strings", check options for saving and loading background and layout.
2. Set RichViewEdit.EditorOptions = [rvoCtrlJumps]


What the heck is this referring to? I can't find any right-click menus that offer a "Settings" option that relate to these components.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This text was written for TRichViewEdit.
For TSRichViewEdit, the proper values of SRichViewEdit.RichViewEdit.Options are set by default.
Actions must work with TSRichViewEdit automatically.

Instructions.
1) Add actions to your project. Possible solutions:
a) Place TActionList component on form/datamodule, place TImageList component, assign it to ActionList.Images. Then add actions one by one in TActionList designtime editor, using "New Standard Action" command.
or
b) Create a copy of dmAction unit (datamodule containing all RichViewActions) and add it to your project.
If you place actions in datamodule, make sure that this datamodule is created BEFORE any form that uses the actions from it (Project | Options, Forms, arrange forms in the list so that this datamodule is the first)

2) Create toolbar button or menu item. Assign some RichViewAction to its Action property. This is all: you have a working command.
Or you can copy-paste toolbar and menu from the ActionTest demo.

3) For ScaleRichView, the following actions are useless: print, quick print, preview, page setup. Replace them with your code (see the ActionTest demo)

4) Add the following statement to the initialization section:

Code: Select all

  RVA_GetRichViewEditFromPopupComponent := 
   SRVGetRichViewEditFromPopupComponent;
It allows TRVAPopupMenu to work with TSRichViewEdit properly.

5) Localization is important, even if you use only English.
See Localize procedure in the demo. Notice, it is called in FormCreate.
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Post by toolwiz »

Ok, that's helpful. Thanks.

In my present case, it's not a "standard" action, but one I want to work "close to" a standard action, like the Edit|Copy action.

When you highlight a string, this button is enabled, and a menu item is available on the right-click context menu along with the standard Edit actions.

I used the OnUpdate to enable the button.

I'm using the OnExecute method of the action to implement the action. Is this correct?

How to I include a menu item on the right-click context menu? Do I just add it to the menu in the OnUpdate method as well?

-David
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, you can place TAction and process OnUpdate and OnExecute.

In new versions of RichViewActions, there is more convenient action - TrvActionEvent. You can add it as "standard" action, it is in "RVE Custom" group of actions.
In this action, you use OnUpdate and OnExecute too, but
- they have Editor parameter (useful if you have several editors in application);
- it respects RVAControlPanel.ActionsEnabled and its Disabled property.
Post Reply