I have a custom look and feel that overrides some of the popup methods. All of them work as expected, except my implementation of getIdealPopupMenuItemSize never gets called – the base class LookAndFeel::getIdealPopupMenuItemSize is used instead.
I was sure this must be some kind of declaration problem on my part, either a typo in the name or one of the variable types being wrong or something, but that’s not it.
When the ItemComponents are created, they figure out their size in the c’tor. They don’t know about the cusom LookAndFeel, so a default is used.
I hacked in some code to deal with this in PopupMenu::Window’s c’tor:
[code] PopupMenu::ItemComponent* const itemComp = new PopupMenu::ItemComponent (*menu.items.getUnchecked(i), standardItemHeight);
// hack itemComp->setLookAndFeel(menu.lookAndFeel); int itemW = 80; int itemH = 16; itemComp->getIdealSize (itemW, itemH, standardItemHeight); itemComp->setSize (itemW, jlimit (2, 600, itemH)); // end of hack items.add (itemComp); addAndMakeVisible (itemComp); itemComp->addMouseListener (this, false);
Might be a cleaner way to do that though.