ComboBox label access and/or minimum popup menu height


#1

Hi Jules,

I have small combo boxes and would like to have a minimum height for the popup menu entries.

Currently I have overriden showPopup to achieve this but I cannot retrieve the label as it's private.

 

What would be the best way to achieve this ?

 

Thanks,


#2

Can you do it with a lookandfeel?


#3

Nop, this is related to the PopupMenu creation in the combo box and I didn't see any override related to this in the LnF

 

I have to do this


namespace
{
  static void comboBoxPopupMenuFinishedCallback(int result, juce::ComboBox* combo)
  {
    if (combo != nullptr)
    {
      combo->hidePopup();
      if (result != 0)
        combo->setSelectedId(result);
    }
  }
}
void MyComboBox::showPopup()
{
  juce::PopupMenu menu;
  menu.setLookAndFeel(&getLookAndFeel());
  addItemsToMenu(menu);
  menu.showMenuAsync(juce::PopupMenu::Options().withTargetComponent(this)
    .withItemThatMustBeVisible(getSelectedId())
    .withMinimumWidth(getWidth())
    .withMaximumNumColumns(1)
    .withStandardItemHeight(std::max(14, /*label->*/getHeight())),
    juce::ModalCallbackFunction::forComponent(comboBoxPopupMenuFinishedCallback, (juce::ComboBox*)this));
}

But I would'nt mind being able to do it in the LnF FWIW


#4

in the lnf you can change the font height in Font getPopupMenuFont(), that should work

By the way it would be great if it was : getPopupMenuFont (PopupMenu&)

There are a few methods like that in the lnf, without any ref to the component, and that's often annoying


#5

It seems getIdealPopupMenuItemSize can do the trick.

 

Thanks,