Selective Dark Mode?

I am currently working on adding support for Dark Mode to my app (both MacOS and Windows), and have run into a puzzle. When Dark Mode is active, windows turn dark, as does all of their contents. For the most part, I’m very happy that the controls, etc. automatically darken.

However, there are parts of some windows that I not want to go dark. For instance, one window is where the user sets up page layout, drawing graphics, lines, text, and pictures on it and ideally all of that would stay its normal color against a white background. For instance, in Apple’s Pages app, when you switch to Dark Mode, the pages still have a white background with black text, only the surrounding borders and controls switch to dark versions of themselves.

Is there a way to tell Xojo that certain controls should not respond to dark mode? Or am I stuck with having to individually customize everything?

You could use Color Groups, but set the dark and light modes to be the same color, instead of having one dark, and one light.
When the user switches to light mode (or dark mode) the rest of the UI will change, but the UI that uses your custom color groups with identical colors for dark/light won’t change.

I’ve been considering this kind of color groups, but it gets complicated really fast because users can draw in any color, or select different colors for different areas of text. I do have code that basically reverses the effects of dark mode coloring, but that means applying that (via a function or whatever) to any possible color. It really makes me wonder what Apple does in their apps.

For macOS, there’s a declare you can use to specify whether you want light or dark mode for particular views.

Where would I look to find that? If there’s one for macOS, then hopefully Win has one, too.

Used fixed color values for drawing those views, or if it’s a text editor, fix the text color to almost black 1% and the background color to almost white 99%.

Otherwise as Greg says, on the macOS you can force a view a use specific appearance theme.

Fixing the text color to almost black and the background to white might do the trick, everything else should be fairly straightforward after that. Thank you!

1 Like

That way it should work x-plat.