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:
parent
e6ea21d1ae
commit
3bb8dbe3ac
1 changed files with 24 additions and 13 deletions
|
|
@ -530,24 +530,35 @@ static void comboBoxPopupMenuFinishedCallback (int result, ComboBox* combo)
|
|||
|
||||
void ComboBox::showPopup()
|
||||
{
|
||||
PopupMenu::MenuItemIterator iterator (currentMenu, true);
|
||||
const int selectedId = getSelectedId();
|
||||
PopupMenu noChoicesMenu;
|
||||
const bool hasItems = (currentMenu.getNumItems() > 0);
|
||||
|
||||
while (iterator.next())
|
||||
if (hasItems)
|
||||
{
|
||||
PopupMenu::Item &item = iterator.getItem();
|
||||
PopupMenu::MenuItemIterator iterator (currentMenu, true);
|
||||
const int selectedId = getSelectedId();
|
||||
|
||||
if (item.itemID != 0)
|
||||
item.isTicked = (item.itemID == selectedId);
|
||||
while (iterator.next())
|
||||
{
|
||||
PopupMenu::Item &item = iterator.getItem();
|
||||
|
||||
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)
|
||||
.withItemThatMustBeVisible (getSelectedId())
|
||||
.withMinimumWidth (getWidth())
|
||||
.withMaximumNumColumns (1)
|
||||
.withStandardItemHeight (label->getHeight()),
|
||||
ModalCallbackFunction::forComponent (comboBoxPopupMenuFinishedCallback, this));
|
||||
PopupMenu& menuToShow = (hasItems ? currentMenu : noChoicesMenu);
|
||||
menuToShow.setLookAndFeel (&getLookAndFeel());
|
||||
menuToShow.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
|
||||
.withItemThatMustBeVisible (getSelectedId())
|
||||
.withMinimumWidth (getWidth())
|
||||
.withMaximumNumColumns (1)
|
||||
.withStandardItemHeight (label->getHeight()),
|
||||
ModalCallbackFunction::forComponent (comboBoxPopupMenuFinishedCallback, this));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue