devxlogo

Create a Context Menu

Create a Context Menu

Question:
I’m having a problem creating a context menu in a grid (by clicking on the right button of the mouse). I created this menu by programming a method that calls the right-click event of the grid. But I can’t associate a method with a pad by using ON SELECTION BAR .

Here my code:

DEFINE POPUP Menucont FROM MROW( ), MCOL( )SHORTCUT TITLE "Pistes du CD" COLOR SCHEME 4DEFINE BAR 1 OF Menucont PROMPT '

Answer:
You are using THISFORM in the ON SELECTION command. THISFORM is only valid when executed from within a method of a form. Once the popup is activated, you are no longer in the method of the form. Therefore, THISFORM cannot be evaluated.

The solution to your problem is to use the ActiveForm reference on the _SCREEN object. _SCREEN.ActiveForm is a reference to the currently active form and can be evaluated outside of method code (it is like a global THISFORM).

To fix your problem, change your ON SELECTION command to the following:

ON SELECTION BAR 1 OF Menucont ;  _SCREEN.ActiveForm.Btnnew.CLICK()

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist