Xojo example project
An example Xojo project to show how to deal with Xojo's DarkMode Support to customize the application's appearance on macOS and Windows.
macOS 10.14 has introduced DarkMode. Xojo just provides a Build Setting Supports DarkMode
. The built application will then appear in Dark- or Lightmode, according to the current system setting.
This example project shows how to override this, so that your application can provide a user preference allowing the application to appear in Always Dark
, Always Light
- or of course the System Default
.
DarkMode on Windows is... not that good - at least not for Win32 Apps/Controls, which is what Xojo is currently using. For that reason it is best practice to explizitly allow the user to Opt-in
for DarkMode support of your application. Many Windows users love to have their system setting to have dark appearance in apps, but might dislike that in Win32-apps.
Starting with Xojo 2021r3, Xojo supports DarkMode for TargetWindows
. This example project shows how to allow the users to Opt-in
for DarkMode support, because Xojo by default always uses the system settings.
Note: Unlike macOS, you can never have the application show in DarkMode on Windows if 'app appearance setting' is 'Light Mode'.
macOS in DarkMode, but application in Always Light
macOS in LightMode, but application in Always Dark
Windows in DarkMode and user's app-preference: DarkMode Opt-in: no
, so application will appear in Light
Windows in DarkMode and user's app-preference: DarkMode Opt-in: yes
, so application will appear in Dark
Xojo is a rapid application development for Desktop, Web, Mobile & Raspberry Pi.
The Desktop application Xojo example project AppAppearance.xojo_project
is using:
- Xojo 2024r1.1
- API 2
Note: You'll need to build with Xojo 2021r3 or later to get DarkMode Support on TargetWindows
- Copy the Module
modAppAppearance
from the example project, and paste it into your project. - Study the example project to learn how to use the provided methods in the Module.
- Windows: The Opt-In happens in
App.Open
:Windows_DarkMode_OptIn = true|false
- macOS: You can switch the appearance any time. See actions in the corresponding
PushButtons
, e.g.:macOSAppAppearance = NSAppearanceType.Light|Dark|Default
- Windows: The Opt-In happens in
Juerg Otter is a long term user of Xojo and working for CM Informatik AG. Their Application CMI LehrerOffice is a Xojo Design Award Winner 2018. In his leisure time Juerg provides some bits and pieces for Xojo Developers.
Do you like this project? Does it help you? Has it saved you time and money?
You're welcome - it's free... If you want to say thanks I'd appreciate a message or a small donation via PayPal.