What version of Xojo? In 2021r3 I can get the textcolor of both a label and a desktoplabel. Is it possible you have an instance of wMain that’s called something else when you run it? Where are you trying to call your code?
I am trying to override the IsDarkMode so that we can gain some form of sanity on Linux. Since a Label is properly changing depending on the user’s Theme settings, I thought to override IsDarkMode as follows:
#if TargetLinux
If SomeLabel.TextColor is Greater than mid-gray Then
Return True
Else
Return False
#else
Return Color.IsDarkMode
#endif
I don’t get the TextColor but only set it to what I need:
if self.Control(currentControl) isA Label then
if doEnable then
Label(self.Control(currentControl)).TextColor = colors.getMainColor
else
Label(self.Control(currentControl)).TextColor = colors.getDisabledLabelColor
end if
end if
That’s not what I’m trying to do - Because Color.IsDarkMode is basically a NoOp on Linux, I need to determine if the platform Theme has changed the Text color based on the Dark/Light mode in effect at the moment. In this case, the TextColor is &c00000000 at design time, so the text is displayed as Black if the Theme is in light mode and white (or nearly white) in dark mode.
This is why I’m looking at the TextColor of a Label - Labels do follow the theme because they are native GTK objects unlike Canvas, ListBox, and others that we must manage the colors at runtime.
But, I still need to determine what the theme is set to display to allow me to make that choice.
Ah, I totally missed the bit about dark mode and IsDarkMode not being supported on Linux. Sorry about that. Hopefully Christian or a linux guru can help you find an appropriate call for that.
The problem is that there is no way in GTK to get the theme info. most app authors solve this by providing a preference switch instead of automatically switching.