Popup menu font size only affecting Section's heading

I have lost more time I want to admit with this :slight_smile:

I have a plain vanilla ComboBox. On my defaulted look and feel I have implemented overrides for “getComboBoxFont”, “getPopupMenuFont” and “getLabelFont”.

The text size for the ComboBox itself works correctly (although I note that it’s coming as a Label to label callback). Then inside “getPopupMenuFont” I’m just fetching the size of the parent ComboBox font and setting the PopUpMenu font size to that value. The interesting thing is that it seems that with “getPopupMenuFont” I’m only affecting the section headings, those get bigger, but the elements on the popupmenu under the headings stay the same size. Why?

You probably need to override LookAndFeel_V4::drawPopupMenuItem().

It modifies the height of the font:

        auto font = getPopupMenuFont();

        auto maxFontHeight = (float) r.getHeight() / 1.3f;

        if (font.getHeight() > maxFontHeight)
            font.setHeight (maxFontHeight);

        g.setFont (font);

You may also need to override LookAndFeel_V4::getIdealPopupMenuItemSize() to control the size of each item in the popup menu, to properly accomodate changes to the font size.

Thanks! I will try tomorrow. It’s still weird that I can make the headings bigger on its default size but I guess you are into something here :slight_smile:

I’m just passing along some of the things I had to do to gain complete control over my popup menus. :person_shrugging:

1 Like

See also:

        void drawPopupMenuItem();
        void drawPopupMenuBackground() ;
        void drawPopupMenuSectionHeader();

You were right. For future reference when someone searches; what I did is basically to remove that check that you pointed on “drawPopupMenuItem” and another similar check on “getIdealPopupMenuItemSize”, so the ideal height returned (“int& idealHeight” argument passed to “getIdealPopupMenuItemSize”) is taken as a constant factor of the actual font size.

1 Like