I’m encountering an unexpected issue with item IDs when using a PopupMenu in a ComboBox and it’s ComboBox Attachment. Here is the function I’m using to add items and submenus:
void MyAudioProcessorEditor::addPopupForAlgorithmComboBox(juce::ComboBox& comboBox)
{
juce::PopupMenu* menu = comboBox.getRootMenu();
if (menu == nullptr)
return;
menu->addItem(1, "Default");
juce::PopupMenu analogMenu;
analogMenu.addItem(2, "Tube");
analogMenu.addItem(3, "Tape");
analogMenu.addItem(4, "Overdrive");
analogMenu.addItem(5, "Diode");
... more sub menus
menu->addSubMenu("Analog", analogMenu);
.. add all sub menus
}
The issue:
- For the “Diode” item (ID 5), the expected attachment value is item ID - 1. However, during debugging, it unexpectedly aligns with 5 instead. (IDs before are correct and “Overdrive” prints 3 with
DBG(algorithmParameter->load());) - Additionally, the behavior changes further on, skipping IDs (e.g., jumping from ID 11 to ID 13). After “Diode” (ID 5), the IDs increment correctly (6, 7, etc.), but discrepancies still occur.
I’m curious about why this happens and how to fix it.
Thanks!
