Loading an RTF into a Styled Text Textfield does not recognize Dark Mode

As part of an installer that I’m working on, I load the EULA into a TextField with Styled Text enabled. This works properly and looks good if the app is running in light mode. However, in dark mode, the textfield background picks up the system dark color, but the displayed text remains black.

The Only things set in the RTF file are the font, font size, and normal black text and was edited in TextEdit on the Mac.

I have “Supports Dark Mode” enabled in the shared settings
In the TextArea, the text color is set to 255, 255, 255 (&cFFFFFF00), and the background color is set to 0, 0, 0 (&c00000000), and Allow Styled Text is enabled.

Here’s my loading code:

f = App.ExecutableFile.Parent.Child("Tools").Child("License.rtf")
tis = TextInputStream.Open(f)
stdata.RTFData = tis.ReadAll
WMain.taLicense.StyledText = stData

Xojo 2022r4.1, Linux and macOS 10.14 and 12.6.3

Use Color.IsDarkMode to detect dark mode, and change the text color accordingly.

https://documentation.xojo.com/api/graphics/color.html#color-isdarkmode

Tried that, but the issue is that the text being loaded is RTF, so it’s not as simple as setting the text.color to white from my tests.

Here, I change the TextArea TextColor to White (otherwise same code):

f = App.ExecutableFile.Parent.Child("Tools").Child("License.rtf")
tis = TextInputStream.Open(f)
stdata.RTFData = tis.ReadAll
If Color.IsDarkMode Then
  WMain.taLicense.TextColor = &cFFFFFF00
End If
WMain.taLicense.StyledText = stData

Sorted it -

f = App.ExecutableFile.Parent.Child("Tools").Child("License.rtf")
tis = TextInputStream.Open(f)
stdata.RTFData = tis.ReadAll
If Color.IsDarkMode Then
  stData.TextColor(0, LenB(stData.Text)) = &cFFFFFF00
End If
WMain.taLicense.StyledText = stData

If this is for Mac only, you can use declares to load the RTF directly into the TextEditor as it preserves the special colors so that text uses the system text color not just a rasterized color.

It’s for all desktop platforms.