Menuitems not enabled

I’m trying to dynamically populate a menuitem on the main menubar called “Songbooks”. I am able to populate it but not to make the items selectable. I’ve done contextual menus and know that I can use this routine to create them. But on the main menubar, I’m not sure what to do. For one thing, I don’t know how to insert menu handlers dynamically … if it all.

Here’s the code:

f = SpecialFolder.Documents.Child("OpenSong").Child("Songs") for folderCount = 1 to f.Count f1 = f.Item(folderCount) if f1.Directory then FileItem = mid(FileItem,P+1) SongbookMenu.Append (new MenuItem (FileItem) ) end if next

you need a menuhandler

here an example

change the MyMenuItem.Action to your needs

Also take a look at these example projects, which use a MenuItem subclass to dynamically add menu items:

  • Examples/Desktop/Menus/OpenRecentMenu
  • Examples/Desktop/Menus/WindowMenu
  • Examples/Desktop/Menus/FontMenu

Thanks to both of you. I think I get it now. The example you sent Axel really helped.