Combo box issue when emtpy


#1

After I make combo box emtpy and click it, add some items to it programmatically.
Then it does not respond to click event and there is no popup, but it shows selected item.
Without click when empty, it does work.

JUCE v4.3.1


#2

Can you show us a code snippet that would reproduce this?


ComboBox with sub menus in the JUCE code
#3

I can confirm there is an issue when the user clicks on any ComboBox with no entry added yet, and then if he clicks again on the ComboBox after some entries have been added. The PopupMenu doesn’t show up then.

I have written a solution, which will solve also another problem my code had, which was the fact that the variable noChoicesMessage wasn’t used anymore… (see here ComboBox with sub menus in the JUCE code)

With that code, the PopupMenu problem is solved, and a PopupMenu displaying the content of noChoicesMessage appears when there is no item in the ComboBox :

void ComboBox::showPopup()
{
    if (currentMenu.getNumItems() == 0)
    {
        PopupMenu menu;
        menu.addItem(1, noChoicesMessage, false, false);
        
        menu.setLookAndFeel(&getLookAndFeel());
        menu.showMenuAsync(PopupMenu::Options().withTargetComponent(this)
            .withItemThatMustBeVisible(getSelectedId())
            .withMinimumWidth(getWidth())
            .withMaximumNumColumns(1)
            .withStandardItemHeight(label->getHeight()),
            ModalCallbackFunction::forComponent(comboBoxPopupMenuFinishedCallback, this));
    }
    else
    {
        PopupMenu::MenuItemIterator iterator(currentMenu, true);
        const int selectedId = getSelectedId();

        while (iterator.next())
        {
            PopupMenu::Item &item = iterator.getItem();

            if (item.itemID != 0)
                item.isTicked = (item.itemID == selectedId);
        }

        currentMenu.setLookAndFeel(&getLookAndFeel());
        currentMenu.showMenuAsync(PopupMenu::Options().withTargetComponent(this)
            .withItemThatMustBeVisible(getSelectedId())
            .withMinimumWidth(getWidth())
            .withMaximumNumColumns(1)
            .withStandardItemHeight(label->getHeight()),
            ModalCallbackFunction::forComponent(comboBoxPopupMenuFinishedCallback, this));
    }
}

Tell me guys if this can be added in the JUCE code and if the problems are solved now (for me it worked on a project where I have been able to reproduce the issue).

Sorry about the inconvenience !


#4

Thanks @IvanC. We’ll add this!


#5

Glad this has been raised, I though I was going mad!


#6

OK. A fix for this will appear on develop soon!