How to get "Display Dialog" dialogs to adhere to dark mode

I have a applet which uses Display Dialog quite a lot to ask the user questions etc. When the system is in Dark Mode, some of those dialogs adhere to Dark Mode while others not. I have no code which interrogates or tries to change the Dark Mode setting. I’d just like the applet to always adhere to what mode the user has set.

The dialogs in the applet which don’t adhere to Dark Mode are not inside a Tell group. So, I have thought that Display Dialog would adhere to Dark Mode if in a Tell group (e.g. tell application “System Events” or “Finder”). But, in testing with a simple script saved to an applet, it makes no difference – all dialogs adhere to Dark Mode including those not inside a Tell group.

So, my question is, why would some “Display Dialog” dialogs in an applet not adhere to Dark Mode ?

It’s going to depend, in part, on what version of the OS the applets displaying the dialogs were saved under. Could that be a factor in what you’re seeing?

Yes, it could but, I’ve not done enough rigorous testing to identify the differences between the OSs. But, in both, when I moved a dialog out of a System Events tell group, the dialog went from dark to light, which made me think the tell group was significant.

If I run the applet from Script Editor, all the dialogs are in Dark mode. If I run it stand alone, only one dialog is in Dark mode (the call is inside a tell System Events group). But, in other parts of the applet, display dialog inside a tell System Events still does not respect the Dark mode setting. So, using tell groups to call Display Dialog is not a complete solution.

Also, I created a very simple applet to just call display dialog (no other code). In Mojave and Catalina it respected Dark mode. That makes me think there’s something in my applet in particular that’s affecting whether Dark mode is respected or not.

More research to do.

Many thanks.

My experience in Mojave was that a dialog panel needed to have a displayed title to make it display in the already selected system dark mode. Otherwise it would display as light. I cannot remember if it was the case in just a display dialog, or with the more complex ‘set answer to choose from list’ structure. But the necessity of having a panel with a title to ensure a dark mode display sticks in my mind.

Thanks. All my dialogs have a “with title [variable]” parameter which shows in the title bar. Is that what you mean ?

Try to set your display dialog into the following tell block. The following test shows that it doesn’t matter if the dialog has a title or not:


tell application "System Events" to tell appearance preferences
	set dark mode to true
	display dialog "myDisplay dialog" with title "Dark mode is true"
	display dialog "myDisplay dialog"
end tell

I had the same problem after switching to mojave.
The solution is straightforward.
Simply copy paste your code (and the scripts loaded or running from your code) into new documents and save a fresh copy of everything.

Just editing and saving older code documents isn’t enough to apply dark mode consistently throughout all your scripts. There’s nothing I could add.

I bought Script Debugger a few days ago and have been editing my applet in that since. Noticed today that all my applet’s dialogs are now in dark mode (matching my preferences). SD might have solved that issue.