Darkmode firing but can't change

I have this code in the activate event but the color of the text in dark mode is always white (latest Xojo, macOS 10.15.7) What could be stopping it from making the text Black?

if color.IsDarkMode then
  self.BackgroundColor = color.DarkGray
  rectangle1.FillColor = color.DarkGray
  label1.TextColor = color.Black
  self.BackgroundColor = color.LightGray
  rectangle1.FillColor = color.Gray
  label1.TextColor = color.Black
end if

I have not used Darkmode, but from https://documentation.xojo.com/topics/user_interface/desktop/macos/supporting_macos_dark_mode.html I think using color.Black will make the label white in Darkmode and black in Ligthmode:

  • Controls whose text defaults to Solid Black (&c00000000) will automatically use the system’s Text Color (except Label, see below), which changes depending on Light or Dark mode.

Thanks, was just reading that and if you stay away from black and white you can set your own colours :slight_smile:

While I strongly oppose putting extra code in the paint event that isn’t needed, system colors do need the paint event as that is the only time (which I know of) where you can guarantee that you’re going to get the most appropriate color.


Why do you want black text on a black background and not white text?

There is actually a image background, covering 3/4 of the screen :slight_smile:

Yep, for this specifc requirement (i.e always black regardless of darkmode), just use
label1.TextColor = &c010101

1 Like

I had a bad surprise lately concerning my eyes and I can tell you white text on a black background is far better than the opposite (strange, but true). At the same text size, I wa able to read with the former, while not in the later.
Also, contrast between the two colors is very important; I have a drug from pharmacy whose background is dark-red (!) and the text color is… black. Even with magnifyng glasses, I was not able to read…

Now, you are the developer, and your target may have perfect eyes / younger than me.

I find exactly the opposite. But what else are preferences for?

It was not preference, my eyes were… disabled.

Now, selecting a fle name was guessing…

Things improved lately and I go back to standard view.

1 Like