It used to be the case that when Appearance Changed fired it was too soon to do the correct assessment of what colors to grab
You can / should only do that in paint events AFTER that event has fired
@Norman Palardy: if that were the case then I should have problems when starting in LightMode, too. Also the whole app doesn’t switch as you can see in the black toolbar.
But testing is always good. I added an App.SleepCurrentThread(100) to the AppearanceChanged event. And there is no change in behaviour.
All I can say is that in my largest app I have waited until the next paint event to grab the correct colors and never have this issue going either way regardless of what mode I started in
The colours aren’t the problem. If they were then I would end up in a sort of Frankenstein mode. If you look at the toolbar then you can see that the complete app is in DarkMode. If I open new windows they are also in DarkMode.
Xojo versions: 2019r3 and 2020r1
Older version: going to test tomorrow. Also going to test older versions of my app.
Rebooting: yes, the problem persists.
Window hiding: doesn’t make a difference.
Can you manually set it to DarkMode / LightMode? E.g.
UseDarkMode = DarkMode
// can we simulate dark mode
Dim nsWindowObj As NSWindowMBS
Dim appearanceObj As NSAppearanceMBS
nsWindowObj = w.NSWindowMBS
If IsDarkMode Or UseDarkMode Then // use DarkMode
appearanceObj = NSAppearanceMBS.appearanceNamed(NSAppearanceMBS.NSAppearanceNameVibrantDark)
Else
appearanceObj = NSAppearanceMBS.appearanceNamed(NSAppearanceMBS.NSAppearanceNameVibrantLight)
End If
If appearanceObj <> Nil Then
NSAppearanceMBS.setAppearance(w, appearanceObj)
End If
End Sub
You might be able to test for the color shown and try to set the mode manually accordingly.