Alpha Q&A #010
How Alpha supports Dark Mode ?


Question

How Alpha supports Dark Mode ?

Answer

Dark Mode is a feature that allows Mac users to switch to a completely different darker interface that adjusts everything on the screen, system-wide.
A partial implemention of this mode appeared in version 10.13 (High Sierra) of OS X but the complete feature was introduced in version 10.14 (Mojave). Prior to Mojave, you could only turn on Night Shift and you could use a dark menu bar and dock.
Dark mode can be activated and deactivated at the system's level from the General System Preferences panel.
Alpha fully supports Dark Mode and offers a few additional features.
When Dark mode is activated, all window frames, icons, dialog boxes and menus in Alpha are redrawn darker. The only exception is the background of the text area in document windows: since Alpha provides syntax hilighting, the syntax colors may render poorly if the background is too dark. So, by default, the background color is left as is (white by default). But some may find it easier on the eye to also have a darker background: there is a preference called Allow Dark Mode Text to control this behavior. It is located in Alpha's Appearance Preferences panel. If this preference is enabled, the text area of document windows will have a darker background color when Dark Mode is activated.
Alpha Dark Mode preferences

In that case, by default, the background of the text area is painted in light 80% gray. The color used can be changed with the Dark Background Color preference also found in the Appearance Preferences panel.
The following two images show the difference:
Dark mode with white background Dark mode with gray background

Note for developers

AlphaTcl package writers can query the current theme in their scripts using the following command:
    getAppInfo darkMode
It returns 1 if the dark mode is active, 0 otherwise.
There is also a themeChangedHook with which you can register a proc to invoke when the user changes the mode in the System Preferences.

Related Links