ItemComponent
ignores custom components for section headers. Adding a test for whether customComp
is nullptr
would prevent this from happening in cases where a custom component has already been provided. Users wouldn’t be able to inherit from HeaderItemComponent
but a custom section header would still be simple enough to implement.
This is also helpful because there’s not a way to resize the section header independently from normal items. (getIdealPopupMenuItemSize
only has a flag for whether the item is a separator – it’d be great to have an enum instead or separate methods, but that’d be a bigger breaking change.)
ItemComponent (const PopupMenu::Item& i, int standardItemHeight, MenuWindow& parent)
: item (i), customComp (i.customComponent)
{
if (item.isSectionHeader) // change to (item.isSectionHeader && customComp == nullptr)
customComp = *new HeaderItemComponent (item.text);
if (customComp != nullptr)
{
setItem (*customComp, &item);
addAndMakeVisible (*customComp);
}
parent.addAndMakeVisible (this);
updateShortcutKeyDescription();
int itemW = 80;
int itemH = 16;
getIdealSize (itemW, itemH, standardItemHeight);
setSize (itemW, jlimit (1, 600, itemH));
addMouseListener (&parent, false);
}