How exactly do I get this to show up in a menu when not using PopupMenu::addCustomItem( );
I’m having no luck with the following:
class ColorTeaser : public juce::PopupMenu::CustomComponent
{
public:
ColorTeaser(const juce::Colour& c) : color(c) { }
~ColorTeaser() {}
void paint(Graphics& g) override
{
DBG( "ColorTeaser::paint()" ); //this never gets called
g.fillAll(color);
g.setColour(Colours::black);
g.drawRect(0, 0, getWidth(), getHeight(), 3);
}
//this also never gets called
void getIdealSize(int &idealWidth, int &idealHeight) override { idealWidth = 20; idealHeight = 20; }
private:
juce::Colour color;
};
juce::PopupMenu::Item noteOnColor;
noteOnColor.commandManager = commandManager;
noteOnColor.customComponent = new ColorTeaser(pianoRoll.getKeyboard().findColour(MatkatMusic::ExtendedMidiKeyboardComponent::ColourIds::keyDownOverlayColourId));
noteOnColor.itemID = (int) commands->commandNoteOnColor;
noteOnColor.text = commandManager->getCommandForID (commands->commandNoteOnColor)->shortName;
menu.addItem(noteOnColor);
The menu item shows up and functions correctly, but that ColorTeaser component just won’t appear in the menu!! It’s driving me bonkers!!
edit:
Ok, it turns out that if you’re using setMacMainMenu(), you can’t have custom items in your menus. That should definitely be in the documentation for PopupMenu::addCustomItem(), etc…
