How to change font size of combobox items?

sdsdddsds

How can i change the size of rows ? I also want to centre texts but i couldn’t find a way to do it :confused:
i tried to change the font but it didnt work. I am able to change the label font but it only works for one that appears in the green background. Others dont change and it is hard to read

1 Like

For the center text, you could use combo.setJustificationType(Justification::centred);. That works fine for me.

For font, it seems it’s more complicated. I read this thread and looks like you’ll have to override some LookAndFeel methods. I tried just using myLookAndFeel.getComboBoxFont(combo).setHeight(100); and other stuff but couldn’t get it to work, so I think your best bet is to go that way. I can’t really help with the details of it because I’m a bit of a noob.

1 Like

You need to set up a custom LookAndFeel class, and then override getComboBoxFont(), and replace the contents of that with your code that changes the size of the font. Just use the contents of the getComboBoxFont() in the LookAndFeel you are overriding as an example. It will be something like:

    return { jmin (16.0f, box.getHeight() * 0.85f) };

Just play with the numbers… Sorry I can’t be more detailed than that, I’m doing something a bit more complicated, but that should be the basics.

2 Likes

thank you all :slight_smile: but it didn’t work for me :smiley: it is really weird. I am able to change the label text but nothing changes the dropdownmenu font or size .

Looks like the whole lookAndFeel of combobox should be changed. There is a class (“ComboBox::LookAndFeelMethods”) in combobox . I think it uses popup menu to create that dropdown menu. So in onder to change it those methods should be overridden . i tried but i got many linking errors :/it would be a bit more possible if there were some solid mistakes that i can read their error messages and debug that particular part of code that error message refers to but linking errors…they are really annoying . I dont even know where to look. Is there any examples that i check ? or can anybody help me to override these methods ? An expert is needed :smiley:

Sorry about that. You need to override getPopupMenuFont() as well. But make sure you are doing the customLookAndFeel class correctly. You should only need to override a few methods, such as the two mentioned here. Did you do the LookAndFeel tutorials?