PopupMenu Ticked with Image


Hi all,

I am trying to create a popupmenu, with both the tick mark and a image along side it.

menu.addItem (1,T("xyz"), true, true,image);

But this shows the image but no tick. Am I doing anything wrong or juce doesn’t support both. Since this code works fine.

menu.addItem (1,T("xyz"), true, true);

I haven’t tested it on windows yet.


I think it might not handle both… No reason why not, really - it could move the item across a bit when both are there. Sorry, bit too busy to change that right now, though…


Hi Jules,
It looks like you don’t support both tick and image.

void LookAndFeel::drawPopupMenuItem (Graphics& g,
                                     int width, int height,
                                     const bool isSeparator,
                                     const bool isActive,
                                     const bool isHighlighted,
                                     const bool isTicked,
                                     const bool hasSubMenu,
                                     const String& text,
                                     const String& shortcutKeyText,
                                     Image* image,
                                     const Colour* const textColourToUse)

        if (image != 0)
            g.drawImageWithin (image,
                               2, 1, leftBorder - 4, height - 2,
                               RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false);
        else if (isTicked)
            const Path tick (getTickShape (1.0f));
            const float th = font.getAscent();
            const float ty = halfH - th * 0.5f;

            g.fillPath (tick, tick.getTransformToScaleToFit (2.0f, ty, (float) (leftBorder - 4),
                                                             th, true));