Is there a way to filter items in KnownPluginList::addToMenu()?

I would like to have popup menus in my app that display only a specific category sorted by manufacturer. Specifically I have “Add Instrument” and “Add Effect” buttons that show popup menus. Is there a straight forward way to do this that I am missing? I thought I might just make the call then post filter the popup menu but I don’t see any way of programatically traversing a menus items. See also:

If it helps anyone else this is how I am currently accomplishing this:

    std::unique_ptr<juce::KnownPluginList::PluginTree> pluginTree(pluginList.createTree(KnownPluginList::sortByManufacturer));
    std::unordered_map<int, String> pluginIds;
    int menuItemID = 100; // Arbitrary

    for (const auto& subFolder : pluginTree->subFolders) // Manufacturers
        PopupMenu subMenu;
        for (const auto& plugin : subFolder->plugins)
            if (plugin->isInstrument)
                subMenu.addItem(menuItemID, plugin->name, true, false);
                pluginIds[menuItemID] = plugin->createIdentifierString();

        if (subMenu.getNumItems() > 0)
            instrumentMenu->addSubMenu(subFolder->folder, subMenu);

    const int result = instrumentMenu->show();
    PluginDescription* pd = pluginList.getTypeForIdentifierString(pluginIds[result]);

Make sure you use createIdentifierString() not PluginDescription::fileOrIdentifier

1 Like