Window.ConstructContextualMenu not working as expected

I am trying to have the menu that is adding show only with a Left Click on a button.
I add the ConstructContextualMenu event to the button with theXoJo example code:
Notes says: "Fires whenever it is appropriate “, this is vague and ambiguous.
" If you return True, the contextual menu is displayed” , it displays with True or False.
Right click on the button always displays it. i just want it to display with left Click only.

#Pragma unused x
#PRAGMA unused y

// Add some items
base.AddMenu(New MenuItem(“Test 1”))

Var m As MenuItem
m = New MenuItem(“Test 2 - Disabled”)
m.Enabled = False
base.AddMenu(m)

Return False

The everyday term for Contextual Menu is “right-click menu”. It’s the alternate mouse button (or cmd-click on macOS!) The alternate mouse button can be configured (swap right and left) so it’s best to avoid calling it “right-click menu”

ConstructContextualMenu will be raised if the user alternate-clicks, regular click (or left mouse button) will not raise ConstructContextualMenu

To show a menu on regular click, you’ll need to do that with MouseDown and MenuItem.Popup

2 Likes

That is the expected behavior.

To show a menu when clicking a buton…

Just use the normal Action event of the button. Create there the MenuItem and use its Popup method.

I was trying to find the Xojo equivalent to the vb.net ContextMenuStrip and that was all i could find. The MenuItem.Popup is the same as what im trying to accomplish.

Thanks guys

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.