Contextual Menus in Scintilla

The ScintillaControlMBS control in MBS Xojo Plugins comes with a standard contextual menu and you may not have any need to change it. Here you see screenshots from Mac and Windows:

But you can replace it with a custom menu. First you need to toggle off the default menu with calling UsePopup method:


Then you implement ConstructContextualMenu event in Xojo:

Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean System.DebugLog CurrentMethodName // Add some items base.AddMenu( New MenuItem(“Test 1”)) base.AddMenu( New MenuItem(“Test 2”)) base.AddMenu( New MenuItem(“Test 3”)) Return True End Function

As you see we just add 3 dumy menu entries. Yours should have some tag values so you can later do a SELECT CASE on it to run right method.

When user selects an entry, the ContextualMenuAction event runs:

Function ContextualMenuAction(hitItem as MenuItem) As Boolean System.DebugLog CurrentMethodName If hitItem <> Nil Then MessageBox "Clicked: "+hitItem.Text End If End Function

If you use newer Desktop controls with DesktopScintillaControlMBS control, the MenuItem parameter will use DesktopMenuItem class. And the ContextualMenuAction event gets a SelectedItem as DesktopMenuItem.


Please try in 22.1: MonkeyBread Software Releases the MBS Xojo Plugins in version 22.1