Change the font of a ComboBox Row

I have a ComboBox that lists my System Fonts.

Is there a way to apply a (different) font to each of the list rows so that I can display the font name in the font face?

Thanks in Advance.

http://documentation.xojo.com/api/deprecated/combobox.html
http://documentation.xojo.com/api/deprecated/popupmenu.html#popupmenu-fontname

The second link comes from the first (in Properties → FontName).

i think you can achieve this with a ListBox where the rows can painted with a TextShape.
i remember in one of my projects i use a Label at top of the combo box and show the selected font there.

This is my code (running in a Method)

Var thisFontName As String
Var thisRow As Integer

For i As Integer = 0 To System.LastFontIndex
thisFontName = System.FontAt(i)
FontDrp.AddRow(thisFontName)

thisRow = FontDrp.LastAddedRowIndex

FontDrp(thisRow).FontName = thisFontName // ERRORS
FontDrp.FontName(thisRow) = thisFontName // ERRORS
Next i

The last 2 lines (before the Next i) both fail the complier.
How do I address the last added row?

I’m pretty sure you can’t. I think the only solution is to fake the drop down part with a list box so you can draw the styles text in the paint event.

Thanks Kevin, I think you’re right. I don’t really want to implement a ‘work-around’ by using a ListBox.

I hear you.
We had a similar problem but also wanted child rows that could be expanded or collapsed.
In the end we had to build the drop down part from scratch ourselves using the MBS plugins + lots of declares. It was a lot of work (maybe 10 days) but gives us more flexibility such as adding the translucency effect that now occurs on drop downs in Big Sur.

I wonder if the same trick for a popup menu would work on a Combobox…

Hi Sam.

Were you referring to my reply about how we build our own version? If you were then it is actually a Xojo combo box we have this hooked up to.

Sorry, my thought are out of line with the conversation. What I meant is that its possible to make a PopupButton display font names in the actual font, and I was wondering if it would work with a ComboBox. I’ll take a look when I got a spare 5 minutes.

Hello Ken,
I have created a selection demo on a canvas
maybe it can be used as a basis for your problem

https://www.dropbox.com/s/rn54bmvya9sgot7/Fontincanvasmenue.xojo_binary_project?dl=1

Why a ComboBox and not a PopupMenu ?

Draw as a list box with a background
https://www.dropbox.com/s/xeq20si0lewbb0c/Fontinlistboxmenue.xojo_binary_project?dl=1