Thursday, August 13, 2020

#1 2020-03-01 07:05:57 pm

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 67
Website

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 ?


Public servants are people too

iMac (late 2009), 27", 2.66GHz i5, 12GB, 1TB SSD, HD4850
macOS Mojave, 10.14.6

Offline

 

#2 2020-03-01 09:04:42 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6440

Re: How to get "Display Dialog" dialogs to 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?


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Online

 

#3 2020-03-03 12:07:38 am

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 67
Website

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

Shane Stanley wrote:

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.


Public servants are people too

iMac (late 2009), 27", 2.66GHz i5, 12GB, 1TB SSD, HD4850
macOS Mojave, 10.14.6

Offline

 

#4 2020-03-09 01:19:42 pm

TheKrell
Member
Registered: 2020-03-08
Posts: 6

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

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.

Offline

 

#5 2020-03-12 10:12:20 pm

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 67
Website

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

TheKrell wrote:

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.


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


Public servants are people too

iMac (late 2009), 27", 2.66GHz i5, 12GB, 1TB SSD, HD4850
macOS Mojave, 10.14.6

Offline

 

#6 2020-03-12 11:20:30 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1265

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

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:

Applescript:


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


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#7 2020-03-14 03:16:36 am

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 643
Website

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

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.

Offline

 

#8 2020-04-25 12:01:00 am

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 67
Website

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

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.


Public servants are people too

iMac (late 2009), 27", 2.66GHz i5, 12GB, 1TB SSD, HD4850
macOS Mojave, 10.14.6

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)