Contextualmenu

Hi,

is it possible to call contextualmenu to be popped up by left click of the mouse or in a push button?
tap and hold on a tablet PC seems not working properly on ubuntu 20 64 bit.

thanks
regards,
arief

Hi, Arief!
What you likely want to do is create a MenuItem with the items you wish to display, which you can then call the Popup function of.

For example:

Var m as new MenuItem 'Create the base item
m.AddMenu( new MenuItem( "Item Text" ) ) 'Create and add a child item

Var mRet as MenuItem = m.Popup 'Show the menu and capture the item selected, if any
If mRet <> Nil Then 'Make sure a child item was selected
    If mRet.Value = "Item Text" Then 'See if it's the item we're looking for.
        'It is, so we do some action here.
    End If
End If
2 Likes

If you wish to show your current window’s EditMenu, then this can be accomplished, according to the documentation on the MenuItem page, by doing the following:

Var m As MenuItem
m = EditMenu.Popup

Hi Mr. Cyphers,

I am forgot to tell that the contextualMenu is already made in a listbox, so when I do right-clicking the mouse, the menu is shown.

so how to call that constructContextualMenu in a listbox from a pushbutton ?

thanks
arief

I would move the code to build the menu to a method that returns the items, then you can use the code above to call that method, or just append the items in ConstructContextualMenu.

2 Likes