How can I add a submenu to a NSPopUpButtonControlMBS?
dim p as NSPopUpButtonMBS = me.View
dim a as new MyCocoaMenuItemMBSp.addItemWithTitle “Hello”
p.addItemWithTitle “World”a = new MyCocoaMenuItemMBS
a.CreateSeparator
p.menu.addItem(a)
How can I add a submenu to a NSPopUpButtonControlMBS?
dim p as NSPopUpButtonMBS = me.View
dim a as new MyCocoaMenuItemMBSp.addItemWithTitle “Hello”
p.addItemWithTitle “World”a = new MyCocoaMenuItemMBS
a.CreateSeparator
p.menu.addItem(a)
Well, continue with the code:
Dim p As NSPopUpButtonMBS = Me.NSPopUpButtonMBS
Dim a As New NSMenuItemMBS
p.addItemWithTitle "Hello"
p.addItemWithTitle "World"
a = New MyCocoaMenuItemMBS
a.CreateSeparator
p.menu.addItem(a)
Dim s As New MyCocoaMenuItemMBS
s.CreateMenuItem "I have a submenu"
p.menu.addItem(s)
Dim se As New MyCocoaMenuItemMBS
se.CreateMenuItem "I am in the submenu"
se.Enabled = True
Dim sm As New NSMenuMBS
sm.addItem(se)
s.submenu = sm
so you make a new menu entry and put in submenu property with a new menu.
This doesn’t work:
Dim p As NSPopUpButtonMBS = Me.NSPopUpButtonMBS
Only this works:
Dim p As NSPopUpButtonMBS = Me.View
But I can’t see the submenu.
The original code is from “Examples/MacFrameworks/Cocoa Controls/Cocoa Controls”
I have tested this example on my new MacBook Pro with M1 CPU and I can’t see a submenu item. If I run this example on my old MacBook Prom with Intel Core i7 CPU, I can seen the submenu entry.
The submenu example is working fine on this M1 running Big Sur.
Here is an example project: https://tim.gdn/TIN0Z
This example project is licensed for anything except training AI.
Older plugins maybe?
Or what could be the difference between them?
The submenu item is only available or visible with Release 2023.R1.1
In 2023R2 the submenu is not visible.
If I use the EnabledSubmenuItem, the menu is visible an enabled in “2023R2” , but the “Action” event is not used, if I select a submenu item.
I have added this event to EnabledSubmenuItem:
Sub Action() Handles Action
System.DebugLog “Submenu was Selected”dim p as NSPopUpButtonMBS = Window1.NSPopUpButtonControlMBS1.View
dim m as NSMenuItemMBS = p.selectedItem
if m<>nil then
Window1.log CurrentMethodName+“: “+m.title
else
Window1.log CurrentMethodName+”: no selection”
end ifEnd Sub