Supporting dark mode in desktop web content

Now that Xojo supports macOS Mojave Dark mode with the release of Xojo 2018r3, it is very easy to get an app supporting Dark mode.

However if your app uses HTMLViewers in some areas, the background will remain white when switching to Dark mode.
There is an easy fix for this using Dark_HTMLViewer now available on Github: https://github.com/jkleroy/Xojo-Dark-HTMLViewer

I can’t get this to work in my project. I copied the Dark_HtmlViewer to my main project. Changed the super of my HtmlViewer to Dark_HtmlViewer. Then I added

if IsDarkMode then HTMLViewer1.ChangeAppearanceToDark end if

in the Open event of the HtmlViewer (just for testing). When I run my app I see only white on white. A bit later I see some text but black on white and not vice versa. My html is loaded with a thread/timer combo because it’s email data from a database.

Any idea what might go wrong here?

Xojo 2018r3, latest Mojave beta.

Do you have a css or style defining background to white ?

Dark_HTMLViewer defaults to dark when setting ChangeappearanceToDark, but your CSS is still the main style driver, so it won’t be overridden.

No styles. I wanted to start with some simple html.

I just understood the problem. You need to call ChangeAppearanceToDark in the DocumentComplete event

Thanks, I’ll try that.

Did it work correctly @Beatrix Willius ?

I had tried again but it didn’t work. Need to make a more complicated example.