Tried that code… background and title works…
But text fields still white, and labels still black…
[quote=390730:@Helge Tjelta]Tried that code… background and title works…
But text fields still white, and labels still black…[/quote]
I was working on it, I think Xojo is overwriting the default values or because the app is not linked, it’s not getting the correct values.
I can get a black text field with white text (using correct NSColors), however the moment you click in to edit the text the background turns white. Same for the Combo box. Ironically it works on El Cap (with dark vibrance), I don’t have to do anything for the Combo box. At least now we get dark dialogs, unlike El Cap.
Actually, if you work in a film or music editing environment, dark mode is a blessing. When you’re working in FCP X, Adobe Premiere Pro, Davinci Resolve, or Media Composer, you’re working in a dark scheme layout that takes over the entire screen. To have a - by reference - garishly bright other app pop up duing a session is quite disruptive.
Do I like the idea of needing to rewrite major chunks of my apps? Not one bit. But, I saw the writing on the wall last year, so most of our apps are already heading there:
The only issue is the controls that Xojo doesn’t allow us tio theme and weighing the work involved in creating a custom control versus having the light “oddity” on the UI.
We’re between a rock and a hard place with this one. To properly support a dark theme, it looks like Xojo will need to link against the 10.14 SDK. As Sam has pointed out, explicitly setting one theme or the other seems to be a bit wonky. Maybe that will get better, maybe it won’t. But Xojo won’t link against 10.14 before release, and odds are it’ll take them years to push that far forward. That leaves us, as Xojo users, in a really bad spot. Apps without dark mode support will stand out like a sore thumb, and for me personally, that would definitely affect my purchasing decision. It’s similar to finding iOS apps that don’t support the large screen phones: why should I bother with an app that is too lazy to properly support my setup?
In my book, dark mode support is something that MUST happen and it must happen soon, but is very unlikely to happen soon. Hopefully we find good workarounds while Xojo spends a few years figuring out how they want to handle this, similar to the HiDPI transition.
It ain’t over until the fat lady sings, and I’m a long way from finding a fat lady. I have a couple more
Ideas, I’ll try in the morning.
My old eyes can’t cope with something like that. I don’t look forward to testing. I need contrast.
I’m the wimp who:
got major headaches from new neon lamps
got not-as-bad headaches from having a monitor at 2000x instead of 2500x (mainly because of the then tiny fonts in Xojo)
said no to a Citrix solution after about 10 seconds (same as having a monitor at a lower solution)
I can’t use Pixelmator at all
[quote=390797:@Sam Rowlands]It ain’t over until the fat lady sings, and I’m a long way from finding a fat lady. I have a couple more
Ideas, I’ll try in the morning.[/quote]
No, of course not. It’s only the second day.
Ok, this code will enable dark mode for your app based on the user’s preference and is safe for systems 10.9+ (maybe earlier). It does NOT watch for changes. That’s another project for another day.
Based on what I’ve seen of this, supporting dark mode in Xojo apps is going to be an uphill battle. Labels do not respect the system settings, scrollbars draw very badly, tab panels… whoa those are bad.
But you can at least use this to experiment with.
[code]#if TargetMacOS
Declare Function NSClassFromString Lib “Foundation” (ClassName As CFStringRef) As Integer
Declare Function NSSelectorFromString Lib “Cocoa” (SelectorName As CFStringRef) As Ptr
Declare Function RespondsToSelector Lib “Cocoa” Selector “respondsToSelector:” (Target As Integer, SelectorRef As Ptr) As Boolean
Declare Function SharedApplication Lib “Foundation” Selector “sharedApplication” (Target As Integer) As Integer
Dim SharedApp As Integer = SharedApplication(NSClassFromString(“NSApplication”))
If RespondsToSelector(SharedApp, NSSelectorFromString(“setAppearance:”)) Then
Declare Function StandardUserDefaults Lib “Foundation” Selector “standardUserDefaults” (Target As Integer) As Integer
Declare Function StringForKey Lib “Foundation” Selector “stringForKey:” (Target As Integer, Key As CFStringRef) As CFStringRef
Declare Sub SetAppearance Lib “Foundation” Selector “setAppearance:” (Target As Integer, AppearanceRef As Integer)
Dim Mode As String = StringForKey(StandardUserDefaults(NSClassFromString("NSUserDefaults")), "AppleInterfaceStyle")
Dim DesiredAppearance As Integer
If Mode = "Dark" Then
Declare Function NSAppearanceNamed Lib "Foundation" Selector "appearanceNamed:" (Target As Integer, Name As CFStringRef) As Integer
DesiredAppearance = NSAppearanceNamed(NSClassFromString("NSAppearance"), "NSAppearanceNameDarkAqua")
End If
SetAppearance(SharedApp, DesiredAppearance)
End If
#endif[/code]
That was on my list of things to try, which is use fs_usage to monitor cfprefsd and see which files get updated when the theme is changed.
As I’m sure you’ve seen, docs recommend using key-value observing to watch for changes.
On the subject of dark modes… we should think about Windows 10’s dark mode too.
[quote=390708:@Beatrix Willius]Christian to the rescue as usual?
I’ll still file this new feature under “things the world doesn’t need”.[/quote]
And how. I shall turn it off wherever it rears its ugly head. We got rid of white text on a black background 35 years ago and I still don’t miss it.
I copy / pasted your code in App.Open, run and nothing happens.
What must I do (El Capitan, just curious).
[quote=390969:@Emile Schwarz]I copy / pasted your code in App.Open, run and nothing happens.
What must I do (El Capitan, just curious).[/quote]
In El Capitan, nothing will happen, since El Capitan has no dark mode.
I have it working using NSNotifications.
It does have vibrantDark, which is what I’ve been using. It is substantially different however, and I’m going to have to modify all my custom controls so that they look okay on both.
I also need to rewrite the second part of my “Dark side” tutorial to take into account the new Dark mode.
Also my NSVisualEffectViews need updating as they use properties which are now deprecated. There’s been quite a few convenience deprecations , when you can finally find what API has changed.
I misunderstand that. Sorry.
Why would you do that? MacOS 10.14 will offer the user a choice - Light or Dark. So to make your app work correctly, you will need to offer both. Let the user decide which he prefers, not how you like it.
I’m on 10.12.6 and nothing seems to happen for me either.
Menus are white-on-black but nothing else seems to change, even when I remove the
If RespondsToSelector
and
If mode = “Dark”
to force the code.
Change for change sake. As Tim says 'We got rid of white text on a black background 35 years ago ’ …seems strange to be going back to “TTY terminals with pictures” …
If you don’t want your app to go ‘dark’, there’s nothing you need to change right now, in 6 years maybe.
The only real reason I can see considering supporting dark mode, is so that potential customers don’t see the lack of dark mode as a reason not purchase your application. There’s two other possibilities in that a reviewer may knock off some brownie points and you’ll be even less likely to have your application promoted on the Mac App Store. Although from what I hear nowadays, promotion on the App Store can be bought!
As for general consumers especially on the Mac App Store, they couldn’t give two shits if your app looks like a Mac app or not. There are so many top selling apps that are not even half assed attempts to make a reasonable Mac App, just as long as your price is cheap.
Btw I’m not saying that supporting dark mode, is going to make it more likely that your app will be promoted, just if you don’t your app will be considered less.
Well quite. The flat look after Mavericks was also change for change’s sake and is the main reason I’m still on Mavericks. Both these changes are just uglification.
I wrote my app (an email client) for my own use. mainly, although it will be downloadable by whomever, for free, so commercial considerations don’t exist at the minute.
Ive made a quest on the internet about the Dark mode and fashion ?
Then, two or three times someone said try it so I do it (sort of: in disabled I set Invert Colors).
After some minutes, I was bored and wanted to set back to normal, close / shutdown and do something else.
When back, I realized there is a difference: white colours stop dazzling my old eyes. So, there may be another difference beside Sam excellent answer above.
FWIW.