How to add a function that will be triggered when the same item has been selected in the combobox?

You can do it in some tricky but very simple way :wink: After you execute your code (if you have any) in your onChange callback, you should also run this code:

comboBox.onChange = [this]
{
    auto menu = comboBox.getRootMenu();
    auto id = comboBox.getSelectedId();
            
    juce::PopupMenu::MenuItemIterator iterator (*menu);

    while (iterator.next())
    {
        auto item = &iterator.getItem();

        if (item->itemID == id)
        {
            item->setAction ([this] { /* your action here! */ });
        }
        else
        {
            item->setAction (nullptr);
        }
    }
};
4 Likes