How to create a context-menu for a dynamic browse?

Storzum

Member
Hi.

I need to create a context-menu (activated by the right mouse-button) for a dynamic browse.
Where can I find something in the documentation, that can help me?

Thanks.
Storzum
 

jongpau

Member
Hi,

Lookup "CREATE MENU" (MENU widget) and "CREATE MENU-ITEM" (MENU-ITEMwidget) in your Progress online help and/or electronic documentation;that should lead you in the right direction on how to create the menu.

If you are dynamically creating the menu, don't forget to use thePERSISTENT-RUN feature of the triggers, otherwise these will not work.

When you have worked out how to create the menu and each of the menuitems you require, you can assign the handle of the menu to the"POPUP-MENU" attribute of the dynamic browse.

HTH
 

Storzum

Member
OK.
Thanks.
I have placed the define menu - statement in the definitions - section and the create menu - statements in the initializeObjects - section.
But where do I place the trigger-functions of the menu?

My code:

CREATE MENU popmenu
ASSIGN POPUP-ONLY = TRUE
TITLE = "Kontextmenue"
TRIGGERS:
ON choose OF ia DO:
MESSAGE "HA".
END.
END TRIGGERS.

CREATE MENU-ITEM ia ASSIGN
PARENT = popmenu
LABEL = "Buchungs-Info"
TRIGGERS:
END TRIGGERS.

This produces an error.
When I put the trigger in the menu-item - statement, I get an error, too.

And when I do this:

CREATE MENU-ITEM ia ASSIGN
PARENT = popmenu
LABEL = "Buchungs-Info"
TRIGGERS:
ON SELECT DO:
MESSAGE "HA".
END.
END TRIGGERS.

nothing happens, when I click on the menu-item.
 

jongpau

Member
Hi,
It's best not to create your menu dynamically in the definitions(youcan of course do it, but since this is a dynamic menu it is notreallya definition (definitions are declarations of variables,temp-tablesetc).

So, create your menu somewhere in the actual code, for instance inaninternal procedure that you can run when you create your dynamicbrowse(return the handle of the menu as an output parameter).

Like I said in my previous post, when you dynamically createwidgets(and a dynamic menu is a collection of widgets) you need touse"PERSISTENT-RUN" in the triggers.

You can then get something like this in your code (very much simplified):
Code:
..
..
Some code goes here
..
..
CREATE BROWSE brMyBrowser
ASSIGN FRAME =
DOWN = 
(etc)
TRIGGERS:

END TRIGGERS.

RUN ipCreatePopup (OUTPUT menuHandle).

ASSIGN brMyBrowser:POPUP:MENU = menuHandle.
..
..
Some code goes here
..
..
PROCEDURE ipCreatePopup:
  DEF OUTPUT PARAMEYET opMenuHandle AS HANDLE NO-UNDO.

CREATE MENU opMenuHandle
ASSIGN POPUP-ONLY = TRUE
TITLE = "Kontextmenue".

CREATE MENU-ITEM ia ASSIGN
PARENT = popmenu
LABEL = "Buchungs-Info"
TRIGGERS:
  ON CHOOSE PERSISTENT RUN ipMenuClicked IN THIS-PROCEDURE (INPUT ia).
END TRIGGERS.  
END PROCEDURE.

PROCEDURE ipMenuClicked:
  DEF INPUT PARAMETER ipMenuItem AS HANDLE NO-UNDO.

  MESSAGE ipMenuItem:LABEL " has just been clicked."
  VIEW-AS ALERT-BOX INFORMATION.
END PROCEDURE.
 
Top