how to add items to pop-up menu
how to add items to pop-up menu
I asked this earlier but I don't think it was answered completely.
In the Actions Demo, you can right-click on the SRV area and a context menu appears. It's generated by the action framework. I'm not sure if it's one of the popup menus on the form, or if it's generated dynamically.
I added some buttons to the toolbar and created actions for them.
How can I get one of them to appear in the right-click menu? (I don't know where the popup is generated, so I don't know which OnPopup method to hook into.)
Thx
-David
In the Actions Demo, you can right-click on the SRV area and a context menu appears. It's generated by the action framework. I'm not sure if it's one of the popup menus on the form, or if it's generated dynamically.
I added some buttons to the toolbar and created actions for them.
How can I get one of them to appear in the right-click menu? (I don't know where the popup is generated, so I don't know which OnPopup method to hook into.)
Thx
-David
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You cannot add items in TRVAPopupMenu at designtime, you must do it at runtime, in code.
This menu is recreated (existing items are deleted, new items are added) every time before displaying.
First, the default menu items are added. Next, TRVAPopupMenu.OnPopup event occurs.
You can add new items in TRVAPopupMenu.OnPopup event.
This menu is recreated (existing items are deleted, new items are added) every time before displaying.
First, the default menu items are added. Next, TRVAPopupMenu.OnPopup event occurs.
You can add new items in TRVAPopupMenu.OnPopup event.
We're going in circles here. I know how to use the OnPopup event. I assume it needs to be done at run-time. I'm just not sure which one to hook into. There are two popups on the Actions Demo form, but from what I can tell, neither one of them is the one that's used when you right-click on the SRV edit box. How do I find the one that IS used and hook into it without disabling it? It seems to be getting created dynamically. Where?
Thanks
-David
Thanks
-David
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
There is only one TRVAPopup menu in this demo (RVAPopupMenu1), and it is assinged to SRichViewEdit1.PopupMenu property. Use it.
For example, this code adds "Background..." command as the last item:
The second popup menu in this demo (pmFakeDropDown) is assigned to DropDownMenu property of combo-toolbutton for table insertion. This menu is empty and never displayed, but its OnPopup event is used to display a table-size window.
For example, this code adds "Background..." command as the last item:
Code: Select all
procedure TForm3.RVAPopupMenu1Popup(Sender: TObject);
var mi: TMenuItem;
begin
mi := TMenuItem.Create(RVAPopupMenu1);
mi.Action := rvActionsResource.rvActionBackground1;
RVAPopupMenu1.Items.Add(mi);
end;
-
- Posts: 14
- Joined: Tue Jan 11, 2011 7:38 pm
How to implement additions to popup menu at runtime
I am a newbie and was having trouble implementing the addition of actions to the popup menu so they appeared at runtime. Where do I install it in the app.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 14
- Joined: Tue Jan 11, 2011 7:38 pm
To TRVAPopupMenu
To TRVAPopupMenu. I have created an action and applied it to the main menu and a tool button but am having trouble with the right click popup menu in RichViewEdit1 of your demo Rich View Actions app.Sergey Tkachenko wrote:Do you want to add action in TPopupMenu or in TRVAPopupMenu?
I want users to right mouse click which opens up a list so they select data merge tags and drop them into the RichViewEdit1 doc. The main menu item and button are working fine.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Please read this topic from the beginning.
It explains how to add items in TRVAPopupMenu.
Briefly: you cannot do it at designtime because TRVAPopupMenu clears all items before displaying, and then it recreates itself.
To add your item in this menu, use OnPopup event. The example is above in this topic.
It explains how to add items in TRVAPopupMenu.
Briefly: you cannot do it at designtime because TRVAPopupMenu clears all items before displaying, and then it recreates itself.
To add your item in this menu, use OnPopup event. The example is above in this topic.
-
- Posts: 14
- Joined: Tue Jan 11, 2011 7:38 pm
Thanks Sergey
I have only been programming with Delphi for around six months so it is a steep learning curve for me. I have it all working now.