Set TextFont’s Style(s) with TextEdit (TextField and TextArea)

This question arise many times, but for Canvas use. This time, it is for TextEdit (read the subject).

I add to my window a PopupMenu and fill it with the Font names following the LR example.

The question lie about the three supported styles: Bold, Italic and Underline.

On MacOS, the testing/development platform, we have to choose the Font variant (say Courier, Courier.Bold, Courier.Italic or Courier.Underline).

Setting the Bold / SelBold, Italic / SelItalic and Underline / SelUnderline do nothing.

I had hard times with the documentation and at last found nothing.

As an example, some Fonts (in the old time) used Italic and Oblique and… other niceties.

How are we (the developers) supposed to do to apply a style to a TextField / TextArea Text with Xojo ?

I checked the Apple’s TextEdit application in order to have an example on how Apple do that:
They have two lists: one for the Family Name and the second for the Style Name that change depending on the selected Family Name. Beside that, I do not know how they build the Style Name.

I read it several times, but not sure what you want or need.

If you like to list font family and their fonts, you can use our NSFontManagerMBS and NSFontMBS classes.
If you like to use styled text with Cocoa framework, please check NSAttributedStringMBS class.
For a popup, you can use NSPopUpButtonMBS class to access e.g. the menu via NSMenuMBS class. And there in the NSMenuItemMBS you can use attributedTitle to put in a formatted text.

Thank you Christian for your answer.

The first image there is nearly what I coded (to my great surprise; I only have another CheckBox: Standard).

What I want to do is to click in the Bold CheckBox and get the selected text style set to Bold.

Very simple.

Nota: in the three platforms. In the development machine/OS (MacBook Pro / El Capitan), this does not works with the obvious code:

TextField1.Bold = True

Eventually, I can code it that way:

TextField1.TextFont = "Helvetica-Bold"

But the “-Bold” part is pure guessing. This can be Thin, Black, Heavy, Italic, Oblique, etc.

Is it more clear now ?

This line in the Action event of a check box (in a quick testing application) works fine on my Mac:

TextField1.Bold = Me.Value

From the LR:

Mac Fonts

[code]With macOS apps, not all fonts appear as Bold, Italic or Underlined even if those properties are selected. Because of the way MacOS draws fonts, Bold, Italic and Underline are only displayed for fonts that include it as part of the font definition. These settings cannot be applied to any font as they can be on other platforms. Instead, on MacOS Xojo has to look up the specific font to use based on what you set for font properties.

If you are not seeing the font setting you expect, be sure to verify that the font itself supports it, which you can do using TextEdit or the Font Book app.[/code]

I verified.

BTW: The user code (my code) have to be verified on a morning; I think I wrote it too late in the day (or something wrong goes into my code).