How can I add a menu when I right-click on browse widget?
I have tried the following code according to the documentation:
ON RIGHT-MOUSE-DOWN OF br-maint IN FRAME a-frame-maint DO: define variable lv-popupMenu as handle no-undo. define variable lv-popupMenuItem as handle no-undo. define variable b1 as handle no-undo. if self:num-iterations = 0 then return no-apply. else do: self:popup-menu = lv-popupMenu. create menu lv-popupMenu assign popup-only = true title = "Browser menu". create menu-item lv-popupMenuItem assign label = "Scheduler" name = "scheduler" parent = lv-popupMenu. end. END.
Create the menu before the browse widget is displayed and set the browse widget's POPUP-MENU attribute to the menu's handle. Then when you right click on the browse the menu will be automatically displayed (you don't need the RIGHT-MOUSE-DOWN trigger).
You can create a browse and popup menu in AppBuilder to see the code that is generated.
If you are going for dynamic context-menu.
1. Move the code inside RIGHT-MOUSE-DOWN.
2. Mode self:popup-menu = lv-popupMenu after create menu lv-popupMenu.
You might need to verify memory leak. Everytime you right-click, it will create menu handle. I'm not exactly sure if Progress will automatically delete the previous instance because it is out-of-scope or not.
To be sure, I would declare the handles as global variables, and add the following code;
IF VALID-HANDLE(lv-popupMenuItem) THEN
DELETE OBJECT lv-popupMenuItem.
IF VALID-HANDLE(lv-popupMenu) THEN
DELETE OBJECT lv-popupMenu.
Since you decided to use the AppBuilder, you're menu-items should be in the list of controls that you can select to define an ON CHOOSE trigger.
Create the menu before the browse widget is displayed and set the browse widget's POPUP-MENU attribute to the menu's handle. Then when you right click on the browse the menu will be automatically displayed (you don't need the RIGHT-MOUSE-DOWN trigger).
You can create a browse and popup menu in AppBuilder to see the code that is generated.
If you are going for dynamic context-menu.
1. Move the code inside RIGHT-MOUSE-DOWN.
2. Mode self:popup-menu = lv-popupMenu after create menu lv-popupMenu.
You might need to verify memory leak. Everytime you right-click, it will create menu handle. I'm not exactly sure if Progress will automatically delete the previous instance because it is out-of-scope or not.
To be sure, I would declare the handles as global variables, and add the following code;
IF VALID-HANDLE(lv-popupMenuItem) THEN
DELETE OBJECT lv-popupMenuItem.
IF VALID-HANDLE(lv-popupMenu) THEN
DELETE OBJECT lv-popupMenu.
I only had to move self:popup-menu = lv-popupMenu after create menu lv-popupMenu. And it started working.
However, I removed my code and used AppBuilder now to create pop-up menu as you suggested. Thanks.
How to call a procedure or method on any menu-item click?
Since you decided to use the AppBuilder, you're menu-items should be in the list of controls that you can select to define an ON CHOOSE trigger.