How do I handle a change from Dark Mode to Light Mode or vice versa? Let’s say I open my app in Light Mode and change the mode to Dark. Then the current window doesn’t change appearance. All windows I open are in in the old mode. Did I miss anything or is this not supported, yet?
The dark mode change will only work on MacOS 10.14 Mojave.
Technically when you enable the Dark Mode option (under Build Settings) in Xojo or add the below to your info.plist
will tell the app to work with dark mode.
If you set all your font colors to #000000 and background colors to #FFFFFF, the app will automatically switch between dark and light mode automatically.
Under App, you can add an Event Handler “AppearanceChanged” for those controls which doesn’t behave. However this will only handle when the user change the theme while running your app. So you need to also add the same codes to your Window Open Handler.
[code]If IsDarkMode Then
window1.label1.TextColor = Color.green
window1.label1.TextColor = Color.blue
End If [/code]
@Edwin Lau: of course, I’m talking about Mojave. The plist information isn’t needed.
I’m not asking about the colors but about the windows themselves. Sure I can change the colors. But the window doesn’t change between Dark Mode and Light Mode when I change the mode in System Preferences.
See the screenshot below: I started my app in Light Mode. Then I changed to Dark Mode. In the background System Preferences and even Xojo change to Dark Mode. How do I do this in my app? There is a lot of custom drawing. But at least the toolbar should change here.
Start a new project and under the App settings tab, turn on the Enable Dark Mode and see if that app change when you switch between the two appearance.
For the toolbar it should be automatic with that setting enabled. Basically it just inject the tag in the info.plist. without which it remains in the aqua appearance and not the dark or light appearance.
This is odd. For a one-window app the change between Dark and Light Mode works just fine. But in my app there is no change at all. Not even dialog boxes change their mode.
You arent using a PreRelease version, are you?
Youre using 2018r3 and building a 64Bit app?
And your PostBuild Scripts dont mess with Info.plist?
No prerelease version. Yes to 2018r3 and 64bit.
I removed all PostBuild scripts and the mode change suddenly worked. Then I started to add back all scripts. The culprit seems to have been the very last one - a DoCommand “SaveFile”. After removing the script and adding it back everything is now working as it should. Very very odd.
Beatrix, I just downloaded the Mail Archiver X Trial and took a look at your info.plist. It appears that the following key is not found in the info.plist. I’ve added it and rerun your app and now it looks like this in Dark Appearance.
Dark Mode support is coming for the next version of my app. I’ve been working on and off in the last months on Dark Mode. But there was some sort of project corruption.
Actually… when building with 2018r3, that plist entry is required for dark mode.
Haven’t done any builds, yet. But so far everything works fine in the debugger.