Is it possible to keep a contextual menu open when the top level is clicked instead of submenu item

On MacOS when using the following code in the constructcontextualmenu

Dim submenu As New MenuItem("SubMenu") submenu.Append(New MenuItem("SubMenu Test 1")) submenu.Append(New MenuItem("SubMenu Test 2"))

When you click the “Submenu” Item the menu closes.
This is not the case in Finder/Microsoft Word for a menuitem with submenus. If you click it there the menu stays open.
Is there any way to catch the fact that the Submenu was clicked instead of one of the submenu items and prevent the contextual menu from closing?

Maybe using false as the return value in the contextualMenuAction event?

I tried that, but it didn’t seem to work. The menu still gets closed. I only seem to get into the event after the menu is closed (at least that’s what it looks like).

In Xojo you can’t do something.
If you’d use NSMenuItemMBS or NSMenuMBS classes in our plugin, we may be able to do something.

Ok. I’ll check if I can get anywhere with the plugins.
I’ll post updates here if I find anything.

Mmmhh… here on Windows, it does not close.
I’ve a Submenu created in a ListBox ConstructContextualMenu Event like this:

[code]miTop = New MenuItem( “Telefonie Server Diagnose” )

mi = New MenuItem( “Prüfe ob die Rufnummer auf dem Server existiert” )
mi.Icon = search_16
miTop.append( mi )

mi = New MenuItem( “Freeswitch XML Datei betrachten” )
mi.Icon = search_16
miTop.append( mi )

base.append( miTop )[/code]

When i click on the “Telefonie Server Diagnose” entry, the Menu stays open. In the ContextualMenuAction Event, i have no action for the “Telefonie Server Diagnose” entry.

You’ll need a new method clearAction for NSMenuItemMBS class, which I just added.

I sent a new plugin to @Dirk Cleenwerck to test.

Indeed. Difference between Mac and Windows in howit gets handled.
I’ll try what Christian sent me and see if that helps.

The clearAction method indeed does what I want.
Thank you to @Christian Schmitz for providing a quick solution.
Much appreciated.

Welcome :slight_smile: