Can I add a ContainerControl to a NSMenuItemMBS?

I’m trying to add a ContainerControl to a NSMenuItemMBS and it looks that is not working.
Is this possible?

Here is what I’m trying to do:

Dim aMenuItemMBS As New myNSMenuItemMBS

Dim aCC As New myContainerControl
aMenuItemMBS.view = aCC.NSViewMBS

mMenuItems.Append(aMenuItemMBS) // so RB doesn't free the object.

I don’t think creating a new instance of a container control sets everything up. Try putting the container control onto a window and use the view from that instance.


Check if NSViewMBS function gives nil.
You may need to embed the container to window first and then get NSViewMBS and call removeFromSuperView.

1 Like

Thank you for your answers …
Indeed, embedding the ContainerControl intro a window and then use that instance worked.

There is a feedback case to trigger the creation of NSView directly without embedding:

62972 - Allow ContainerControl to create it’s views without embedding

The code is already in the framework. Just expose it as method.

1 Like