In my previous thread I asked how to make a dynamically created menubar properly function: http://macscripter.net/viewtopic.php?id=43812
I am now trying to add a submenu to each of these menu items. I have looked up other tutorials online, but I have not been able to figure out how to integrate them into my code.
Here is a portion of how my current code is set up:
repeat with i from 1 to number of items in mylibrary
set this_item to item i of mylibrary
--display dialog this_item
set thisMenuItem to (current application's NSMenuItem's alloc()'s initWithTitle:this_item action:"someAction:" keyEquivalent:"")
(newMenu's addItem:thisMenuItem)
(thisMenuItem's setTarget:me) -- required for enabling the menu item
set dividerCount to dividerCount + 1
if dividerCount is 4 then
(newMenu's addItem:(current application's NSMenuItem's separatorItem)) -- add a seperator
set dividerCount to 0
end if
end repeat
set quitMenuItem to (current application's NSMenuItem's alloc()'s initWithTitle:"Quit" action:"showQuit:" keyEquivalent:"")
StatusItem's setMenu:newMenu
newMenu's addItem:quitMenuItem
quitMenuItem's setTarget:me
end makeMenus
How could I make it so each of the menu items has a submenu with a fixed amount of clickable items?