I have spent several days trying to get the font heights for the various parts of the FileBrowserComponent (as a list) to be correct, but can’t seem to find any way to do that. I have, for example, this code in my L&F, which I intentionally set to ridiculous sizes so that I could see that my code was working, but it seems to be completely ignored:
juce::Font FileBrowserLookAndFeel::getComboBoxFont(juce::ComboBox &)
{
return getInstrumentSans500().withExtraKerningFactor(-0.12f).withHeight(24.0f);
}
juce::Font FileBrowserLookAndFeel::getPopupMenuFont()
{
return getInstrumentSans500().withExtraKerningFactor(-0.12f).withHeight(8.0f);
}
I also tried something suggested in another post here, but again, nothing seems to happen:
dynamic_cast<juce::FileListComponent\*>(fileChooser->getDisplayComponent())->setRowHeight(32);
How does one set the fonts for the drop-down label, the combobox items themselves, and the file list rows? I just can’t seem to find any way at all to control those.
Ah, that setRowHeight does change the row height, but shrinks the font to match. I want a specific font size and row height without one automatically changing the other. How can I do that?
Looks like the correct override is getTextButtonFont. That seems really weird for a ListBox, but it works. Had to ask Claude to get this answer.
I also had to override drawFileBrowserRow(), because it always sets the font height to 0.7 (or 0.5) times the row height, regardless of what font is used.
And also have to override drawComboBox(), because it also changes the font size based on the box height. Wish that was an optional setting, so we could specify the font size to use without copying all that drawing code! Sigh.
Um, nope. That function does not draw the text, apparently???
So far, I can deal with the font in the listbox and in the dropdown, but not the font in the path box or the filename textedit. Nothing seems to affect those that I’ve tried.
I’ve been able to do all this. I have heavily customized it though. And it was a long while ago.
However, for the filename TextEdit, I seem to be doing this:
filenameBox->applyFontToAllText(ad->getGlobalFont());
That’s a pointer to my global font.
I’m trying to figure out what I might be doing to affect the pathbox. It’s a ComboBox, right? I think I’m just applying my typical ComboBox LookAndFeel to it, I don’t see anything else at the moment.
Well, I managed to get the font to set. Turns out we had inherited from another Look&Feel that overrode the getLabelFont and getComboBoxFont, and was returning a constant font size instead of the font we’d set explicitly in this class. So now I have the fonts correct, BUT…
The drop-down box draws and behaves strangely. There is a second left-hand border being drawn, about a dozen pixels or so to the right of the actual left-hand-side of the box as laid out in my code. AND, if you click on the down arrow in the drop-down, instead of opening the popup menu, it enters editing mode for the box.
-
What could be causing a second border to be drawn?
-
Why does clicking on the down arrow enter edit mode? We don’t want to prevent entering edit mode altogether by making it a read-only file browser, but at the same time, we need that down arrow to open the popup menu.