DarkMode as Preference

Hi. My Apps supports darkMode correctly. They start in DarkMode or LightMode depending on the OS settings. This is working fine in MacOS and also on Windows.

I can check if the darkMode is turn on or off in the OS, but I can’t choose it. The problem is I’d like to enable or disable DarkMode support in the software independently of the OS settings.

So let’s imagine I’ve turn on DarkMode in the OS, but I want to switch off the DarkMode on my app because depending on the monitor and user, the software looks better on LightMode. But I want to have the DarkMode turn on for the same App on other computers, so I can’t just turn off the DarkMode feature for the App.

How can I turn one or on the DarkMode support while running the App (or even when starting the App as I can create a preferences file for checking if DarkMode has to be enabled or disabled).

Thanks for the help.

If you have Ohanaware AppKit or MBS Plugins then it’s real easy. I don’t happen know what the declares are though, sorry.

Have a look at this example project: GitHub: jo-tools/app-appearance.
It shows what’s currently possible with Xojo for macOS (always light | always dark | auto) and Windows (DarkMode: Opt-In). No Plugins required.

That’s exactly what I was looking for. Thanks a lot for the help.

I’ve MBS Plugins, but I’ve not seen anything about it. Can you please tell me witch plugin is related with? (or what example to look into)

Thanks

I don’t have the apparance plugin installed, but from the docs I gather it works like this:

NSAppearanceMBS.setAppearance(self, NSAppearanceMBS.NSAppearanceNameVibrantDark)

// or

NSAppearanceMBS.setAppearance(self, NSAppearanceMBS.NSAppearanceNameVibrantLight)

Reading MBS docs is tricky, but the information is all there:
https://www.monkeybreadsoftware.net/class-nsappearancembs.shtml