classContextualMenu on GitHub

If anyone is interested I have put a class on GitHub which can be used as an alternative to the built in methods and events for contextual menus in Xojo. There are a number of feedback cases relating to an issue with contextual menus which I couldn’t really wait to be resolved so I created this class.

Very simple, easy to use. Do what you want with it, comes with no warranty express or implied. It is what it is but it works. Nothing fancy, 2 methods, 1 event. Bosh menu on your screen.

https://github.com/CharlieXojo/classContextualMenu

clicking on a menu removes the menu “This is a menu item”

did you want that?

Yes, the menu item named “This is a menu item” is added in the open event of the window. It demonstrates that the menu is destroyed after each MenuItemClick event and then re-created as demonstrated in the mousedown event of the Window.

Whoa, wait a sec… Why are you creating the contextual menu in the MouseDown event ?

The mechanism is designed to build the menu in the ConstructContextualMenu event and handle it in the ContextualMenuAction event.

[quote=114037:@Greg O’Lone]Whoa, wait a sec… Why are you creating the contextual menu in the MouseDown event ?

The mechanism is designed to build the menu in the ConstructContextualMenu event and handle it in the ContextualMenuAction event.[/quote]
Because there is a bug in the built in event with base. You are not forced to build the menu in mouse down using my class it can be done anywhere it is just an example