1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixed a bug where ComboBoxes with no itmes wouldn't show the "no choices" entry

This commit is contained in:
hogliux 2017-02-23 10:01:21 +00:00
parent e6ea21d1ae
commit 3bb8dbe3ac

View file

@ -529,6 +529,11 @@ static void comboBoxPopupMenuFinishedCallback (int result, ComboBox* combo)
}
void ComboBox::showPopup()
{
PopupMenu noChoicesMenu;
const bool hasItems = (currentMenu.getNumItems() > 0);
if (hasItems)
{
PopupMenu::MenuItemIterator iterator (currentMenu, true);
const int selectedId = getSelectedId();
@ -540,9 +545,15 @@ void ComboBox::showPopup()
if (item.itemID != 0)
item.isTicked = (item.itemID == selectedId);
}
}
else
{
noChoicesMenu.addItem (1, noChoicesMessage, false, false);
}
currentMenu.setLookAndFeel(&getLookAndFeel());
currentMenu.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
PopupMenu& menuToShow = (hasItems ? currentMenu : noChoicesMenu);
menuToShow.setLookAndFeel (&getLookAndFeel());
menuToShow.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
.withItemThatMustBeVisible (getSelectedId())
.withMinimumWidth (getWidth())
.withMaximumNumColumns (1)